make_classification

这篇博客介绍了如何使用Python中的ADASYN(Adaptive Synthetic Sampling)算法来解决分类任务中不平衡数据的问题。通过`make_classification`生成了一个不平衡的数据集,展示了ADASYN如何重采样以平衡类别比例,从而改善模型训练效果。
摘要由CSDN通过智能技术生成
from collections import Counter
from sklearn.datasets import make_classification
from imblearn.over_sampling import ADASYN
X, y = make_classification(n_classes=2, class_sep=2,
                           weights=[0.1, 0.9], 
                           n_informative=3, 
                           n_redundant=1, 
                           flip_y=0,
                           n_features=20, 
                           n_clusters_per_class=1, 
                           n_samples=1000,
                           random_state=10)

print(X)
print(y)
print('Original dataset shape %s' % Counter(y))
ada = ADASYN(random_state=42)
X_res, y_res = ada.fit_resample(X, y)
print('Resampled dataset shape %s' % Counter(y_res))

make_classification参数注解

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值