如何处理样本分布不均衡

SMOTE过采样算法

参考https://blog.csdn.net/qq_33472765/article/details/86561557

简单来说smote算法的思想是合成新的少数类样本,合成的策略是对每个少数类样本a,从它的最近邻中随机选一个样本b,然后在a、b之间的连线上随机选一点作为新合成的少数类样本。

    model_smote=SMOTE()    #建立smote模型对象
    x_smote_resampled,y_smote_resampled=model_smote.fit_sample(x,y)
    x_smote_resampled=pd.DataFrame(x_smote_resampled,columns=['col1','col2','col3','col4','col5'])
    y_smote_resampled=pd.DataFrame(y_smote_resampled,columns=['label'])
    smote_resampled=pd.concat([x_smote_resampled,y_smote_resampled],axis=1)
    groupby_data_smote=smote_resampled.groupby('label').count()
全部评论

相关推荐

怎么起名字:早知道就不读书了,害得我送外卖还得扶眼镜
点赞 评论 收藏
分享
机械打工仔:我来告诉你原因,是因为sobb有在线简历,有些HR为了快会直接先看在线简历,初步感觉不合适就不会找你要详细的了
投了多少份简历才上岸
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-07 11:20
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务