如何处理样本分布不均衡

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

相关推荐

LazyBreeze:项目尽量体现你对技术的理解和深度,不是说把中间件用一下就完事了,你项目里面提到集群和分布式,你真在服务器上部署过吗,感觉太假了,第二个项目说自己用了微服务的什么组件,只是用了没有自己的思考,很难让面试官注意到你的简历。针对某几个技术点自己多思考一下,考虑一下有没有别的替代方案,可以写一下,即使没有真的实现
点赞 评论 收藏
分享
昨天 10:31
门头沟学院 Java
求问各位大佬,笔试都考点啥
投递科大讯飞等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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