sklearn02

  1. from matplotlib.colors import ListedColormap
    This may be most useful when indexing directly into a colormap, but it can also be used to generate special colormaps for ordinary mapping.
  2. from sklearn.model_selection import train_test_split
    进行数据集划分train_test_split(*arrays,**options)
    *arrays可以是列表、numpy数组、scipy稀疏矩阵或pandas数据框。
  3. from sklearn.preprocessing import StandardScaler 
    StandardScaler他可以在驯良数据集上做了标准转换操作之后,把相同的转换应用到测试训练集中
    例子:
    #调用fit方法,根据已有的训练数据创建一个标准化的转换器
    scaler=StandardScaler().fit(x)
    现在比如来了一组新的样本,也想得到相同的转换
    new_x = [[-1., 1., 0.]]
    scaler.transform(new_x)
  4. from sklearn.datasets import make_circles,make_moons,make_classification 

          make_circles(n_samples=100, noise=0.1):形成环形图,返回值:X (array of shape [n_samples, 2]) – The generated samples.
y (array of shape [n_samples]) – The integer labels (0 or 1) for class membership of each sample.

          make_moons(n_samples=100, noise=0.1):形成形图,返回值:X (array of shape [n_samples, 2]) – The generated samples.
y (array of shape [n_samples]) – The integer labels (0 or 1) for class membership of each sample.

         make_classification(n_samples=100)返回值:X (array of shape [n_samples, n_features]) – The generated samples.
y (array of shape [n_samples]) – The integer labels for class membership of each sample.

5.plt.scatter(x1[:, 0], x1[:, 1], marker='o', c=y1):maker='o'圈

猜你喜欢

转载自blog.csdn.net/caicai1hao/article/details/83994038