如何处理样本分布不均衡

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()
全部评论

相关推荐

zYvv:双一流加大加粗再标红,然后广投。主要是获奖荣誉不够,建议开始不用追求大厂,去别的厂子刷下实习。
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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