python生成香蕉形数据集

from sklearn.datasets import make_moons
import matplotlib.pyplot as plt
import numpy as np

X, Y = make_moons(n_samples=2000,  shuffle=True, noise=0.15, random_state=None)
# plt.scatter(X[:, 0], X[:, 1], c=Y, s=2)

xx = X[np.where(Y == 1)[0]]


# 旋转
alpha = -0.25 * np.pi
A = np.array([[np.cos(alpha), np.sin(alpha)], [-np.sin(alpha), np.cos(alpha)]])

yy2 = np.dot(A, xx.T).T
plt.scatter(yy2[:, 0], yy2[:, 1], s=2)
data = joblib.load('datasets/DS009.pkl')
scaler = MinMaxScaler()
data.iloc[:, 0:-1] = scaler.fit_transform(data.iloc[:, 0:-1])

d1 = data[data['label'] == 5]
d2 = data[data['label'] == 15]
dd = pd.concat([d1.sample(200, replace=True), d2.sample(200, replace=True)])
dd = dd.iloc[:, 1:]
dd.columns = ['总燃料量', '锅炉总风量', '给水流量', '主蒸汽压力', 'A引风机开度', 'B引风机开度', 'label']

import cufflinks as cf
import seaborn as sns
import plotly as py
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot

init_notebook_mode(connected=True)
cf.go_offline()

trace = go.Parcoords(
    line=dict(color=dd['label'],
              colorscale=px.colors.diverging.Tealrose
              ),
    dimensions=list([
        dict(range=[0, 1],
             visible=True,
             label='总燃料量', values=dd['总燃料量']),
        dict(range=[0, 1],
             visible=True,
             label='锅炉总风量', values=dd['锅炉总风量']),
        dict(range=[0, 1],
             visible=True,
             label='给水流量', values=dd['给水流量']),
        dict(range=[0, 1],
             visible=True,
             label='主蒸汽压力', values=dd['主蒸汽压力']),
        dict(range=[0, 1],
             visible=True,
             label='A引风机开度', values=dd['A引风机开度']),
        dict(range=[0, 1],
             visible=True,
             label='B引风机开度', values=dd['B引风机开度']),
    ])
)
data = [trace]

layout = go.Layout(
    paper_bgcolor="white",
    width=800,
    height=300,
    font=dict(size=24, color='black', family='Times New Roman'),
)

fig = go.Figure(data=data, layout=layout)
plot(fig, filename='my-plot.html', auto_open=False)

你可能感兴趣的:(python生成香蕉形数据集)