make_classification函数

make_classification函数

sklearn.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_samplesint100样本数量
n_featuresint20特征总数。这些包括n_informative 信息特征、n_redundant冗余特征、 n_repeated重复特征和 n_features-n_informative-n_redundant-n_repeated随机抽取的无用特征。
n_informativeint2信息特征的数量。
n_redundantint2冗余特征的数量。这些特征是作为信息特征的随机线性组合生成的。(假设n_informative=F1,F2,…那么n_redundant= aF1+bF2+… a,b,c就是随机数)
n_repeatedint0信息特征冗余特征中随机抽取的重复特征的数量。
n_classesint2分类问题的类(或标签)数。
n_clusters_per_classint2每个类的集群数。
random_stateintNone类似随机种子,复现随机数
返回值输出值含义
Xndarray(n_samples, n_features)生成的n+samples个样本
yndarray(n_samples)每个样本的类别成员的整数标签。

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

在不打乱的情况下,X按以下顺序水平堆叠特征:主要n_informative特征,然后n_redundant 是信息特征的线性组合,然后是n_repeated 重复,随机抽取信息和冗余特征的替换。其余特征充满随机噪声。因此,无需改组,所有有用的特征都包含在列中 。X[:, :n_informative + n_redundant + n_repeated]

from sklearn.datasets import make_classification

X, y = make_classification(n_samples=6, n_classes=2, n_features=5, n_informative=5,n_redundant=0,n_clusters_per_class=1)
display(X,y)

"""
n_samples=6 - 6行6个数据
n_classes=2 - 结果分为2类即二分类
n_features=5 - 5个特征
n_informative=5 - 5个全部有效的特征
n_redundant=0 - 冗余特征为0
n_clusters_per_class=1 - 每一个类别聚为一个簇

array([[ 1.10885456, -1.97464085,  2.14372944, -0.08241471, -2.60173628],
       [ 0.98456921, -4.67257395, -0.10161149,  0.52329866,  2.0178222 ],
       [-2.92441307, -2.20249011,  0.12827954,  1.90711152,  0.24340137],
       [ 0.14524134, -1.42685331,  1.92731161, -0.72915701,  1.3529692 ],
       [-0.09694719, -0.28604481, -2.62609999, -0.46131174,  0.72515074],
       [ 0.25540393, -2.64589841, -2.05721611,  0.53203936,  0.34273113]])
       
array([0, 1, 1, 0, 1, 0])
"""

参考:

sklearn.datasets.make_classification (scikit)

修改时间:
2022/1/29

  • 18
    点赞
  • 69
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值