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

scikit-leanr 库中的 make_blobs() 函数的更多相关文章

  1. numpy函数库中一些常用函数的记录

    ##numpy函数库中一些常用函数的记录 最近才开始接触Python,python中为我们提供了大量的库,不太熟悉,因此在<机器学习实战>的学习中,对遇到的一些函数的用法进行记录. (1) ...

  2. 查找库中的某个函数,grep命令的用法。

    程序中调用了某个库中的函数,我想知道这个函数具体的作用,就必须去看这个库的源代码. 那么问题来了:如何从库中众多的.h文件中,得知我想要的函数在哪个文件里? 最后用grep命令成功解决. 具体用法:先 ...

  3. STL库中的正态分布函数

    在设计抽奖一类程序中,有时会需要一种概率“有较大可能获得一个普通结果,有较小可能获得一个糟糕或极好的结果”,这就可以用正态分布函数来获得这样一个结果. STL中已经提供了一系列随机分布的函数,包括正态 ...

  4. jquery.rotate.js库中的rotate函数怎么用。

    rotate是jQuery旋转rotate插件,支持Internet Explorer 6.0+ .Firefox 2.0 .Safari 3 .Opera 9 .Google Chrome,高级浏览 ...

  5. 机器学习之numpy库中常用的函数介绍(一)

    1. mat() mat()与array的区别: mat是矩阵,数据必须是2维的,是array的子集,包含array的所有特性,所做的运算都是针对矩阵来进行的. array是数组,数据可以是多维的,所 ...

  6. Python标准库中的生成器函数

    一.用于过滤的生成器函数 - 从输入的可迭代对象中产出元素的子集,而不修改元素本身 import itertools l1 = [1,2,3,4,5] l2 = [True,False,True,Fa ...

  7. lua的table库中的常用函数总结

    table是Lua语言中的一种重要的数据类型, table 的一些特性简单列举如下: (1).table 是一个“关联数组”,数组的索引可以是数字或者是字符串; (2).table 的默认初始索引一般 ...

  8. python 生成器(四):生成器基础(四)标准库中的生成器函数

    os.walk 这个函数在遍历目录树的过程中产出文件名,因此递归搜索文件系统像for 循环那样简单. 用于过滤的生成器函数 模块  函数  说明 itertools  compress(it,sele ...

  9. Python初探——sklearn库中数据预处理函数fit_transform()和transform()的区别

    敲<Python机器学习及实践>上的code的时候,对于数据预处理中涉及到的fit_transform()函数和transform()函数之间的区别很模糊,查阅了很多资料,这里整理一下: ...

随机推荐

  1. python中使用redis模块, 设置过期时间

    # 链接数据库self.handle = redis.Redis(host=host, port=port, db=db, password=password, decode_responses=Tr ...

  2. 考试总结(橙题WA)

    又逢校内测,成绩变化大 初见三道题,暗喜AK辣 谁知数据毒,特判不到家 三题两题WA,心态已爆炸 T1(我不想再见到这道题): 附上多年前AC但是随便出(毒瘤)一组数据就可以卡掉的代码: #inclu ...

  3. [LeetCode] 719. Find K-th Smallest Pair Distance 找第K小的数对儿距离

    Given an integer array, return the k-th smallest distance among all the pairs. The distance of a pai ...

  4. DVWA SQL Injection 通关教程

    SQL Injection,即SQL注入,SQLi,是指攻击者通过注入恶意的SQL命令,破坏SQL查询语句的结构,从而达到执行恶意SQL语句的目的.SQL注入漏洞的危害巨大,常常会导致整个数据库被“脱 ...

  5. idea maven项目打包并部署到tomcat

    打包 打开Maven管理器,邮寄package,执行Run Maven Build,执行成功后将war包生成到target目录下. 部署 1.将war包复制到tomcat安装目录下的webapps目录 ...

  6. jenkins 更新插件使用代理

    方法一: 管理插件页面配置如下: 这个 URL 改成http://mirror.xmission.com/jenkins/updates/update-center.json 或https://mir ...

  7. nuget安装说明

    1.先百度安装nuget.server 比如 https://www.cnblogs.com/tomfang/articles/3999303.html 2.官网下载nuget.exe nuget p ...

  8. snap应用多版本卸载

    Ubuntu18.04新增了几个内置软件使用Snap格式.同样的沙箱式处理方式,除了Canonical主推的Snap,还有Fedora的Flatpak和AppImage.一般正常使用没问题,就是第一次 ...

  9. 基于 HTML5 WebGL 的 3D 智慧隧道漫游巡检

    前言 这次为大家展示的是通过 HT for Web 灵活的图型化编辑工具打造的智慧隧道监控系统.通过 HTML5 技术实现了桌面和移动端的跨平台性,同时现实了可视化运维. 这次主要跟大家分享里面的漫游 ...

  10. .net Core 学习笔记(实体字段映射,IOC注入)

    https://github.com/wj1034184751/ADO.NetCore.git 先简单的做一个学习架子, EF层用的是 EFCore(2.1.0)+ Pomelo.EntityFram ...