如何处理样本分布不均衡

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

相关推荐

Lorn的意义:你这种岗位在中国现在要么牛马天天加班,要么关系户进去好吃好喝,8年时间,真的天翻地覆了,对于资本来说你就说一头体力更好的牛马,哎,退伍没有包分配你真的亏了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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