scikit-leanr 库中的 make_blobs() 函数
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() 函数的更多相关文章
- numpy函数库中一些常用函数的记录
##numpy函数库中一些常用函数的记录 最近才开始接触Python,python中为我们提供了大量的库,不太熟悉,因此在<机器学习实战>的学习中,对遇到的一些函数的用法进行记录. (1) ...
- 查找库中的某个函数,grep命令的用法。
程序中调用了某个库中的函数,我想知道这个函数具体的作用,就必须去看这个库的源代码. 那么问题来了:如何从库中众多的.h文件中,得知我想要的函数在哪个文件里? 最后用grep命令成功解决. 具体用法:先 ...
- STL库中的正态分布函数
在设计抽奖一类程序中,有时会需要一种概率“有较大可能获得一个普通结果,有较小可能获得一个糟糕或极好的结果”,这就可以用正态分布函数来获得这样一个结果. STL中已经提供了一系列随机分布的函数,包括正态 ...
- jquery.rotate.js库中的rotate函数怎么用。
rotate是jQuery旋转rotate插件,支持Internet Explorer 6.0+ .Firefox 2.0 .Safari 3 .Opera 9 .Google Chrome,高级浏览 ...
- 机器学习之numpy库中常用的函数介绍(一)
1. mat() mat()与array的区别: mat是矩阵,数据必须是2维的,是array的子集,包含array的所有特性,所做的运算都是针对矩阵来进行的. array是数组,数据可以是多维的,所 ...
- Python标准库中的生成器函数
一.用于过滤的生成器函数 - 从输入的可迭代对象中产出元素的子集,而不修改元素本身 import itertools l1 = [1,2,3,4,5] l2 = [True,False,True,Fa ...
- lua的table库中的常用函数总结
table是Lua语言中的一种重要的数据类型, table 的一些特性简单列举如下: (1).table 是一个“关联数组”,数组的索引可以是数字或者是字符串; (2).table 的默认初始索引一般 ...
- python 生成器(四):生成器基础(四)标准库中的生成器函数
os.walk 这个函数在遍历目录树的过程中产出文件名,因此递归搜索文件系统像for 循环那样简单. 用于过滤的生成器函数 模块 函数 说明 itertools compress(it,sele ...
- Python初探——sklearn库中数据预处理函数fit_transform()和transform()的区别
敲<Python机器学习及实践>上的code的时候,对于数据预处理中涉及到的fit_transform()函数和transform()函数之间的区别很模糊,查阅了很多资料,这里整理一下: ...
随机推荐
- 【转】web.xml详解
转载:https://www.cnblogs.com/vanl/p/5737656.html. 一:web.xml加载过程 简单说一下,web.xml的加载过程.当我们启动一个WEB项目容器时,容器包 ...
- Linux查看进程和已知端口是否启动
如查看activeMQ的61616这个端口是否启动,以及直接查看activeMQ进程是否启动,可以通过如下命令进行查看 其中netstat命令必须知道端口,如果能查出就证明已启动,如果查出没有结果则表 ...
- git生成并添加SSH key
1.安装Git Bash https://git-scm.com/downloads 2.鼠标右键git bash here 3.执行以下命令: ① cd ~/.ssh/ [如果没有对应的文 ...
- SpringBoot第十三篇:日志处理
作者:追梦1819 原文:https://www.cnblogs.com/yanfei1819/p/10973583.html 版权声明:本文为博主原创文章,转载请附上博文链接! 引言 日志是软件 ...
- 使用numpy处理数组
def fun_ndarray(): a = [[1,2,7], [-6,-2,-3], [-4,-8,-55] ] b = np.array(a) b = np.abs(b)#取数组的绝对值 pri ...
- 【已解决】C#导入音频文件
C#导入音频文件,找到Resources.resx,再进行导入. 直接添加文件到Resources是不能使用的. 解决的具体步骤: 引用音频文件核心代码: //播放背景音乐 SoundPlayer m ...
- 移动端布局方案—vw+rem
前言 首先你要知道 vw 和 rem 是什么?怎么使用? ①:简单来说 vw 是视口单位,相当于把视口等分成了100,1vw = 1; ②:rem是相对单位,设置根元素 html 的 font-siz ...
- Thinkpad S430 3364-A59 (笔记本型号)加内存条过程
背景:13年初选购的本,目前使用发现卡得厉害,原装内存只有4G,遂寻思扩充内存. [1]准备工具 待准备工具明细: (1)螺丝刀 主要为了卸后盖的螺丝. (2)内存条 待增加的内存条,如下图: 说明一 ...
- Window与Document
Window 表示一个包含DOM文档的窗口,其 document 属性指向窗口中载入的 DOM文档.使用 document.defaultView 属性可以获取指定文档所在窗口.window作为全局变 ...
- What are regsvr32, regasm and gacutil using for?(转载)
What are regsvr32, regasm and gacutil using for? Regasm.exe is used to create COM Callable Wrapper ( ...