sklearn.datasets.make_blobs() 是用于创建多类单标签数据集的函数,它为每个类分配一个或多个正态分布的点集。

sklearn.datasets.make_blobs(
          n_samples=100,        # 待生成的样本的总数
          n_features=2,      # 每个样本的特征数
          centers=3,         # 要生成的样本中心(类别)数,或者是确定的中心点
          cluster_std=1.0,     # 每个类别的标准差
          center_box=(-10.0, 10.0), #中心确定之后的数据边界,亦即每个簇的上下限
          shuffle=True,         # 是否将样本打乱
          random_state=None)      #随机生成器的种子

参数的英文含义:

n_samples: int, optional (default=100)
The total number of points equally divided among clusters. n_features: int, optional (default=2)
The number of features for each sample. centers: int or array of shape [n_centers, n_features], optional (default=3)
The number of centers to generate, or the fixed center locations. cluster_std: float or sequence of floats, optional (default=1.0)
The standard deviation of the clusters.
如果生成2类数据,其中一类比另一类具有更大的方差,可以将cluster_std设置为[1.0,3.0]。 center_box: pair of floats (min, max), optional (default=(-10.0, 10.0))
The bounding box for each cluster center when centers are generated at random. shuffle: boolean, optional (default=True)
Shuffle the samples. random_state: int, RandomState instance or None, optional (default=None)
If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.

返回值

X : array of shape [n_samples, n_features]
The generated samples.
生成的样本数据集。

y : array of shape [n_samples]
The integer labels for cluster membership of each sample.
样本数据集的标签。

示例:

# 导入相关模块
from sklearn.datasets import make_blobs
import matplotlib.pyplot as plt

# 创建仿真聚类数据集
X, y = make_blobs(n_samples=150,
n_features=2,
centers=3,
cluster_std=0.5,
shuffle=True,
random_state=0)

# 绘制散点图
plt.figure('百里希文', facecolor='lightyellow')
plt.scatter(X[:, 0], X[:, 1], c='w', edgecolor='k', marker='o', s=50)
plt.grid()
plt.show()

推荐参考:

https://cloud.tencent.com/developer/article/1406348

最新文章

  1. SpringMVC执行流程
  2. x86和x64的区别
  3. C语言 约瑟夫圈问题:N个人围成一圈,从第一个人开始按顺序报数并编号1,2,3,……N,然后开始从第一个人转圈报数,凡是报到3的退出圈子。则剩下的最后一个人编号是多少。
  4. vs2012 快捷键修改
  5. 养成一个SQL好习惯带来一笔大财富
  6. Eclipse总是自动关闭
  7. 【VBA研究】VBA通过HTTP协议实现邮件轨迹跟踪查询
  8. hdu1565+hdu1569(最大点权独立集)
  9. [ An Ac a Day ^_^ ] CodeForces 426C Sereja and Swaps 优先队列
  10. Arduino线程库ProtoThreads
  11. Python之os.fork
  12. windows下提权基础
  13. java中JScrollPane不显示水平滚动条的解决办法
  14. ★★★kalinux 常用命令
  15. 为帮助保护你的安全,您的Web浏览器已经限制此文件显示可能访问您的计算机的活动内容
  16. Spring 属性注入(三)AbstractNestablePropertyAccessor
  17. yii---获取当前sql语句
  18. 20155328 《Java程序设计》实验三 敏捷开发与XP实践 实验报告
  19. Linux中查看CPU信息 (转)
  20. Eolinker----全局变量的不同场景使用

热门文章

  1. 2.GO-可变参数函数、匿名函数和函数变量
  2. 洛谷p2613【模板】有理数取余
  3. Java Web 之 SSM笔记
  4. CentOS7 Hbase 安装(完全分布式)
  5. Unity和Jenkins真是绝配,将打包彻底一键化!
  6. nginx反向代理配置去除前缀
  7. CI/CD之Gitlab集成Jenkins多分支pipeline实现质量检测和自动发布
  8. AtomicInteger例子
  9. SSL证书格式转换
  10. typora安装自定义主题小计