样本不平衡问题

不平衡问题的产生

机器学习中常常会遇到数据的类别不平衡(class imbalance),也叫数据偏斜(class skew)。
以常见的二分法问题为例,我们希望预测患者是否患有罕见疾病。然而,在历史数据中,阳性率可能很低(例如0.1%)。

[En]

Taking the common dichotomy problem as an example, we hope to predict whether the patient has a rare disease. However, in historical data, the positive rate may be very low (for example, 0.1%).

在这种情况下,很难学习一个好的分类器,在这种情况下得出结论往往是令人困惑的。

[En]

In this case, it is difficult to learn a good classifier, and it is often confusing to get a conclusion in this case.

在上面提到的场景中,如果我们的分类器总是预测一个人没有生病,即预测是一个反例,那么我们仍然有99.9%的预测准确率。然而,这一结果毫无意义,这就提出了今天的第一个问题,在班级失衡的情况下,如何有效地评估分类器?

[En]

In the scenario mentioned above, if our classifier always predicts that a person is not sick, that is, the prediction is a counterexample, then we still have a prediction accuracy of 99.9%. However, this result is meaningless, which raises the first question today, how to effectively evaluate classifiers in the case of class imbalance?

当然,本文希望解决的最后一个问题是:如何在数据倾斜的情况下得到一个好的分类器?如果可能,我们是否能找到一种更简单的解决方案,避免复杂的模型、数据处理,减少我们的工作量。

[En]

Of course, the final problem that this paper hopes to solve is: how to get a good classifier in the case of data skew? If possible, whether we can find a simpler solution to avoid complex models, data processing, and reduce our workload.

以二分类问题为例,undersampling和oversampling主要用于样本中正负比例极度不平衡的情况。比如广告的点击估计、信用卡诈骗识别、得病与否的预测等,通常目标为1的样本比例远小于1%。

出现失衡的情况有两种:

[En]

There are two situations in which imbalances arise:

  • 正负样本的收购成本不同(为简化起见,此处仅讨论两类)
    [En]

    different acquisition costs of positive and negative samples (only two categories are discussed here for simplification)*

  • 不完全标注问题,问题的核心是训练集和测试集的label分布不一致
  • 上采下采本质都是要改变训练数据的分布,让他和真实分布一致
  • 实际分布中本来就不平衡
  • 其实多数不需要采样,只要不用不科学的、愚蠢的评价方法即可

深度学习解决方案

  • 欠采样
  • 过采样
  • 数据增强
    • SMOTE过采样
    • k近邻单词替换
  • 修改损失函数/代价函数优化

文本中的数据增强不太常见,这里我们使用了shuffle和drop两种数据增强,前者打乱词顺序,后者随机的删除掉某些词。效果举例如图:

样本不平衡问题

; 工具与类库

  • imbalanced-learn是一个Python上处理数据不平衡的工具库

Original: https://blog.csdn.net/dzzxjl/article/details/121411478
Author: dzzxjl
Title: 样本不平衡问题

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/514506/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球