• 【机器学习】使用sklearn.datasets.make_gaussian生成数据,python


    python使用sklearn.datasets.make_gaussian生成数据,代码传送门:

    import matplotlib.pyplot as plt
      
    from sklearn.datasets import make_classification
    from sklearn.datasets import make_blobs
    from sklearn.datasets import make_gaussian_quantiles
    from sklearn.datasets import make_hastie_10_2
      
    plt.figure(figsize=(8, 8))
    plt.subplots_adjust(bottom=.05, top=.9, left=.05, right=.95)
      
    plt.subplot(421)
    plt.title("One informative feature, one cluster per class", fontsize='small')
    X1, Y1 = make_classification(n_samples=1000,n_features=2, n_redundant=0, n_informative=1,
                                 n_clusters_per_class=1)
    plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1)
      
    plt.subplot(422)
    plt.title("Two informative features, one cluster per class", fontsize='small')
    X1, Y1 = make_classification(n_samples=1000,n_features=2, n_redundant=0, n_informative=2,
                                 n_clusters_per_class=1)
    plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1)
      
    plt.subplot(423)
    plt.title("Two informative features, two clusters per class", fontsize='small')
    X2, Y2 = make_classification(n_samples=1000,n_features=2, n_redundant=0, n_informative=2)
    plt.scatter(X2[:, 0], X2[:, 1], marker='o', c=Y2)
      
      
    plt.subplot(424)
    plt.title("Multi-class, two informative features, one cluster",
              fontsize='small')
    X1, Y1 = make_classification(n_samples=1000,n_features=2, n_redundant=0, n_informative=2,
                                 n_clusters_per_class=1, n_classes=3)
    plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1)
      
    plt.subplot(425)
    plt.title("Three blobs", fontsize='small')
    X1, Y1 = make_blobs(n_samples=1000,n_features=2, centers=3)
    plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1)
      
    plt.subplot(426)
    plt.title("Gaussian divided into four quantiles", fontsize='small')
    X1, Y1 = make_gaussian_quantiles(n_samples=1000,n_features=2, n_classes=4)
    plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1)
      
    plt.subplot(427)
    plt.title("hastie data ", fontsize='small')
    X1, Y1 = make_hastie_10_2(n_samples=1000)
    plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1)
    plt.show()
    

    效果图:

     本文代码系摘取,链接传送门:https://www.cnblogs.com/wj-1314/p/10179741.html

  • 相关阅读:
    【Git&GitHub idea中使用Git 03】
    【Git&GitHub 本地库和远程库交互 02】
    【Git&GitHub 本地库操作 01】
    C Primer Plus学习笔记【11章节】
    Python包,模块理解,以及通过元类自动化注册属性。
    pandas.DataFrame.from_dict的使用介绍
    C Primer Plus学习笔记 第10章 编程练习
    CMOS与BIOS的区别(转帖)
    Python 元类详解 __new__、__init__、__call__[补充说明]
    Python 元类详解 __new__、__init__、__call__[收官之作]
  • 原文地址:https://www.cnblogs.com/helenlee01/p/12617459.html
Copyright © 2020-2023  润新知