maxframe.learn.datasets.make_blobs#

maxframe.learn.datasets.make_blobs(n_samples=100, n_features=2, centers=None, cluster_std=1.0, center_box=(-10.0, 10.0), shuffle=True, random_state=None)[源代码]#

生成用于聚类的各向同性高斯斑点。

更多信息请参见 用户指南

参数:
  • n_samples (int or array-like, optional (default=100)) -- 如果为 int,则表示所有簇中平均分配的点的总数。如果为 array-like,序列中的每个元素表示每个簇的样本数量。

  • n_features (int, optional (default=2)) -- 每个样本的特征数量。

  • centers (int or array of shape [n_centers, n_features], optional) -- (默认值为 None) 要生成的中心数量,或固定的中心位置。如果 n_samples 是整数且 centers 为 None,则生成 3 个中心。如果 n_samples 是 array-like,则 centers 必须为 None 或者长度等于 n_samples 的数组。

  • cluster_std (float or sequence of floats, optional (default=1.0)) -- 簇的标准差。

  • center_box (pair of floats (min, max), optional (default=(-10.0, 10.0))) -- 当中心随机生成时,每个簇中心的边界框。

  • shuffle (boolean, optional (default=True)) -- 是否打乱样本顺序。

  • random_state (int, RandomState instance or None (default)) -- 确定数据集创建时的随机数生成方式。传入一个 int 可在多次函数调用中获得可复现的结果。参见 术语表

返回:

  • X (tensor of shape [n_samples, n_features]) -- 生成的样本。

  • y (tensor of shape [n_samples]) -- 每个样本所属簇的整数标签。

示例

>>> from maxframe.learn.datasets import make_blobs
>>> X, y = make_blobs(n_samples=10, centers=3, n_features=2,
...                   random_state=0)
>>> print(X.shape)
(10, 2)
>>> y
array([0, 0, 1, 0, 2, 2, 2, 1, 1, 0])
>>> X, y = make_blobs(n_samples=[3, 3, 4], centers=None, n_features=2,
...                   random_state=0)
>>> print(X.shape)
(10, 2)
>>> y
array([0, 1, 2, 0, 2, 2, 2, 1, 1, 0])

参见

make_classification

一个更复杂的变体