maxframe.learn.datasets.make_classification#

maxframe.learn.datasets.make_classification(n_samples=100, n_features=20, n_informative=2, n_redundant=2, n_repeated=0, n_classes=2, n_clusters_per_class=2, weights=None, flip_y=0.01, class_sep=1.0, hypercube=True, shift=0.0, scale=1.0, shuffle=True, random_state=None)[源代码]#

生成一个随机的 n 类分类问题。

该函数首先创建一个正态分布(标准差为 1)的点簇,这些点簇分布在 n_informative 维超立方体的顶点周围,超立方体的边长为 2*class_sep,并将相等数量的簇分配给每个类别。它引入了这些特征之间的相互依赖关系,并向数据中添加了各种类型的噪声。

如果不进行打乱,X 会按以下顺序水平堆叠特征:首先是主要的 n_informative 个特征,然后是信息特征的 n_redundant 个线性组合,接着是 n_repeated 个重复特征,这些重复特征是从信息特征和冗余特征中随机有放回地抽取的。其余特征则用随机噪声填充。因此,若不进行打乱,所有有用特征都包含在 X[:, :n_informative + n_redundant + n_repeated] 列中。

更多信息请参阅 用户指南

参数:
  • n_samples (int, optional (default=100)) -- 样本数量。

  • n_features (int, optional (default=20)) -- 特征总数。这些包括 n_informative 个信息特征、n_redundant 个冗余特征、n_repeated 个重复特征,以及 n_features-n_informative-n_redundant-n_repeated 个随机抽取的无用特征。

  • n_informative (int, optional (default=2)) -- 信息特征的数量。每个类别由若干高斯簇组成,这些簇分布在 n_informative 维子空间中超立方体的顶点周围。对于每个簇,信息特征独立地从 N(0, 1) 中抽取,然后在簇内随机线性组合以增加协方差。这些簇随后被放置在超立方体的顶点上。

  • n_redundant (int, optional (default=2)) -- 冗余特征的数量。这些特征是信息特征的随机线性组合生成的。

  • n_repeated (int, optional (default=0)) -- 重复特征的数量,这些特征是从信息特征和冗余特征中随机抽取的。

  • n_classes (int, optional (default=2)) -- 分类问题的类别(或标签)数量。

  • n_clusters_per_class (int, optional (default=2)) -- 每个类别的簇数量。

  • weights (list of floats or None (default=None)) -- 分配给每个类别的样本比例。如果为 None,则类别是平衡的。注意,如果 len(weights) == n_classes - 1,则最后一个类别的权重会自动推断。如果 weights 的总和超过 1,返回的样本数量可能超过 n_samples

  • flip_y (float, optional (default=0.01)) -- 随机交换类别标签的样本比例。较大的值会在标签中引入噪声,使分类任务更困难。

  • class_sep (float, optional (default=1.0)) -- 超立方体大小的乘法因子。较大的值会使簇/类别分布更分散,使分类任务更容易。

  • hypercube (boolean, optional (default=True)) -- 如果为 True,则簇被放置在超立方体的顶点上。如果为 False,则簇被放置在随机多面体的顶点上。

  • shift (float, array of shape [n_features] or None, optional (default=0.0)) -- 将特征按指定值进行平移。如果为 None,则特征会按 [-class_sep, class_sep] 区间内随机抽取的值进行平移。

  • scale (float, array of shape [n_features] or None, optional (default=1.0)) -- 将特征乘以指定值。如果为 None,则特征会按 [1, 100] 区间内随机抽取的值进行缩放。请注意,缩放是在平移之后进行的。

  • shuffle (boolean, optional (default=True)) -- 打乱样本和特征的顺序。

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

返回:

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

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

备注

该算法改编自 Guyon [1],旨在生成 "Madelon" 数据集。

引用

参见

make_blobs

简化变体

make_multilabel_classification

多标签任务的无关生成器