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()函数之间的区别很模糊,查阅了很多资料,这里整理一下: ...
随机推荐
- python异步编程
python用asyncio 模块实现异步编程,该模块最大特点就是,只存在一个线程 由于只有一个线程,就不可能多个任务同时运行.asyncio 是"多任务合作"模式(coopera ...
- linux在目录下查字符串, 查文件数目
在目录下所有文件中查找某个字符串(递归查) grep -rnl '字符串' 目录名 统计一个文件夹下目录数或文件数, 如下分步讲解: 1. 显示目录下内容: ls -l ...
- 生成指定python项目中所有的依赖文件
一. pipreqs工具 这个工具的好处是可以通过对项目目录的扫描,自动发现使用了那些类库,自动生成依赖清单. 缺点是可能会有些偏差,需要检查并自己调整下. 安装: pip install pipre ...
- HTTP协议,到底是什么鬼?
作者 | Jeskson 来源 | 达达前端小酒馆 了解HTTP HTTP是什么呢?它是超文本传输协议,HTTP是缩写,它的全英文名是HyperText Transfer Protocol. 那么什么 ...
- [LeetCode] 731. My Calendar II 我的日历之二
Implement a MyCalendarTwo class to store your events. A new event can be added if adding the event w ...
- [LeetCode] 287. Find the Duplicate Number 寻找重复数
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), pro ...
- Salesforce 开发新工具 - Visual Studio Code
最近尝试使用Visual Studio Code来做Salesforce的开发工具,体验上比Sublime好用不少,介绍下详细步骤 第一步:下载对应版本的Visual Studio Code 下载地址 ...
- ZJOI 2009 多米诺骨牌(状态压缩+轮廓线+容斥)
题意 https://www.lydsy.com/JudgeOnline/problem.php?id=1435 思路 一道很好的状压/容斥题,涵盖了很多比较重要的知识点. 我们称每两行间均有纵跨.每 ...
- windows远程复制中断无法复制
关掉对应的rdpclip进程,再创建一个
- 为什么我的resharper控件安装之后没有显示
Resharper和Resharper C++有时候会出现,安装之后不显示,VisualStudio菜单栏内找不到的情况,大多数是因为启动VisualStudio的时候没有激活Resharper. 安 ...