sklearn 中 make_blobs模块使用
来源:互联网 发布:cass软件下载 编辑:程序博客网 时间:2024/06/05 09:40
Abstract
ref: http://scikit-learn.org/0.17/modules/generated/sklearn.datasets.make_blobs.html
Generate isotropic Gaussian blobs for clustering.
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)
Parameters
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.
Returns
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.
样本数据集的标签。
Sample
例如要生成5类数据(100个样本,每个样本有2个特征),代码如下:
from sklearn.datasets import make_blobsfrom matplotlib import pyplotdata, label = make_blobs(n_samples=100, n_features=2, centers=5)# 绘制样本显示pyplot.scatter(data[:, 0], data[:, 1], c=label)pyplot.show()
如果希望为每个类别设置不同的方差,需要在上述代码中加入cluster_std参数:
from sklearn.datasets import make_blobsfrom matplotlib import pyplotdata, label = make_blobs(n_samples=10, n_features=2, centers=3, cluster_std=[0.8, 2.5, 4.5])# 绘制样本显示pyplot.scatter(data[:, 0], data[:, 1], c=label)pyplot.show()
- sklearn 中 make_blobs模块使用
- sklearn 中 make_blobs模块的使用
- sklearn学习笔记(1)--make_blobs
- sklearn 模块间的搭配使用
- sklearn中SVM简单使用
- 使用knn和logsitic对make_blobs数据集进行分类
- 使用sklearn中的神经网络模块MLPClassifier处理分类问题
- tf-idf:sklearn中TfidfVectorizer使用
- easy_install 安装sklearn模块
- sklearn dataset模块学习
- sklearn.cross_validation模块
- 使用sklearn
- python中sklearn的朴素贝叶斯方法(sklearn.naive_bayes.GaussianNB)的简单使用
- sklearn学习(模块列表)
- 在sklearn中使用DataFrame的一些问题
- sklearn 使用过程中遇到的问题和解决方法
- 使用sklearn中svm做多分类时难点解惑
- sklearn中k折交叉验证函数使用
- C++ - 计蒜客 - 迷宫中的英雄(bfs)
- MySQL分库分表总结
- CMake学习笔记(4)——使用外部共享库和头文件
- swift json的序列化和反序列化
- 隐马尔可夫模型(六)——隐马尔可夫模型的评估问题(前向后向相结合算法)
- sklearn 中 make_blobs模块使用
- 系统限流实践 - 理论篇
- 静态局部变量
- Java的ClassLoader加载机制
- Android Studio获取SHA1
- kettle源码部署
- js去除数组重复元素
- 自定义SwipeLayout实现侧滑菜单
- 向数据库中插入多条数据