# 欠采样（机器学习）

欠采样是一种面向不平衡分类的数据层面技术，它从多数类中移除样本，使训练集更加均衡，从而削弱多数类对所学分类器的主导地位。其方法可分为受控欠采样与清洗欠采样两类：前者将多数类缩减至用户指定的规模（通常为少数类的样本数），后者的最终各类规模取决于所用方法，无法直接设定。<sup>[1](https://imbalanced-learn.org/stable/under_sampling.html)</sup> 一篇2025年的综述指出，随机欠采样是最早出现的欠采样方法，并指出其存在大量信息丢失的风险。<sup>[2](https://link.springer.com/article/10.1186/s40537-025-01119-4)</sup> 该技术有两种已见于文献的副作用：它通过改变训练先验来扭曲后验概率分布，并通过缩小训练集来增大分类器方差。<sup>[3](https://dalpozz.github.io/static/pdf/ECML_under_v4.pdf)</sup>

| 事实 | 详情 |
|---|---|
| 产出 | 一个缩减后的训练集，其中多数类样本被随机或按选择规则移除。<sup>[1](https://imbalanced-learn.org/stable/under_sampling.html)</sup> |
| 两大类别 | 受控欠采样设定目标类规模；清洗欠采样移除噪声、边界或冗余样本，最终规模取决于方法。<sup>[1](https://imbalanced-learn.org/stable/under_sampling.html)</sup> |
| 副作用 | 后验概率被扭曲（训练先验改变），以及训练样本减少导致分类器方差增大。<sup>[3](https://dalpozz.github.io/static/pdf/ECML_under_v4.pdf)</sup> |
| 基准效果 | 在31个数据集上的56种分类器—采样组合中，采样仅在12.2%的情况下显著改变AUPRC，在10.0%的情况下显著改变AUROC，且更可能降低而非提升性能。<sup>[4](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0271260)</sup> |
| 单边选择 | 将Tomek连接移除（噪声与边界多数类样本）与压缩最近邻规则（远离边界的冗余样本）相结合。<sup>[5](https://www.kdd.org/exploration_files/batista.pdf)</sup> |
| 集成使用 | EasyEnsemble与BalanceCascade在欠采样的多数类子集上训练学习器，报告的AUC、F值和G均值高于许多现有的类别不平衡方法。<sup>[6](https://cs.nju.edu.cn/zhouzh/zhouzh.files/publication/tsmcb09.pdf)</sup> |

## 工作原理

平衡类别先验会改变分类器所学到的内容。在决策边界附近运作的重采样方法会从边界区域移除更多多数类样本，使决策边界向多数类内部偏移；这增加了真阳性（敏感度更高），但引入了更多假阳性（特异度更低）。<sup>[2](https://link.springer.com/article/10.1186/s40537-025-01119-4)</sup>

对树学习器而言，机制更为具体：移除实例会在剪枝生效之前就阻碍许多分支的生长，往往使剪枝变得不必要；而过采样则减少剪枝、泛化更差；Drummond与Holte用代价曲线表明，配合欠采样的C4.5为算法比较建立了合理的标准，而默认设置下的过采样出人意料地无效。<sup>[7](https://www.site.uottawa.ca/~cdrummon/pubs/ICML03.pdf)</sup>

欠采样是否有帮助是有条件的。Dal Pozzolo、Caelen与Bontempi推导出了欠采样改善后验概率排序的条件，并表明其收益取决于样本数、分类器方差、不平衡程度以及特定测试点的后验值，这解释了文献中不一致的结果；他们呈现该结果主要是为了警示不要盲目使用。<sup>[3](https://dalpozz.github.io/static/pdf/ECML_under_v4.pdf)</sup>

## 操作方法

在imbalanced-learn这类库中的工作流程是：选择选择策略（受控或清洗），为受控方法设定目标比例，或让清洗方法自行决定最终类规模，丢弃多数类样本，然后重新训练。在RandomUnderSampler中，对含1,000个多数类样本和100个少数类样本的数据集将sampling_strategy设为0.5，会把多数类缩减至200个样本。<sup>[8](https://machinelearningmastery.com/random-oversampling-and-undersampling-for-imbalanced-classification/)</sup> 该采样器还支持有放回的自助采样，并在多类情形下对每个目标类独立进行欠采样。<sup>[1](https://imbalanced-learn.org/stable/under_sampling.html)</sup> 随机欠采样只是随机删除多数类样本，直至达到所需分布。<sup>[8](https://machinelearningmastery.com/random-oversampling-and-undersampling-for-imbalanced-classification/)</sup>

对受控方法而言，目标以比例表示；在NearMiss中，比例为\( \alpha_{us} = N_{m} / N_{rM} \)，其中\( N_{m} \)是少数类规模，\( N_{rM} \)是重采样后的多数类规模，默认邻居数为三。<sup>[9](https://imbalanced-learn.org/stable/references/generated/imblearn.under_sampling.NearMiss.html)</sup> 重采样必须仅应用于交叉验证折内的训练数据，以避免数据泄漏。<sup>[8](https://machinelearningmastery.com/random-oversampling-and-undersampling-for-imbalanced-classification/)</sup>

## 起源

欠采样源于最近邻分类器的实例选择。P. Hart（P. Hart）在1968年发表于《IEEE信息论汇刊》的一篇通信中引入了压缩最近邻（CNN）规则，该规则寻找训练样本的一个一致子集，即在此子集上构建的1-最近邻分类器能将其正确分类的子集。<sup>[10](https://doi.org/10.1109/tit.1968.1054155)</sup> Dennis L. Wilson（Dennis L. Wilson）1972年发表于《IEEE系统、人与控制论汇刊》的关于使用编辑数据的最近邻规则的论文，是编辑最近邻（ENN）的基础。<sup>[11](https://doi.org/10.1109/tsmc.1972.4309137)</sup> Tomek连接是互为最近邻的异类样本对，可作为清洗标准：若两个样本构成这样的连接，则其中一个是噪声，或两者都处于边界。<sup>[5](https://www.kdd.org/exploration_files/batista.pdf)</sup>

Miroslav Kubát（Miroslav Kubát）与Stan Matwin（Stan Matwin）于1997年使用单边选择对原始总体进行选择性欠采样，应用Tomek连接与CNN规则移除远离决策边界的多数类样本。<sup>[12](https://people.iee.ihu.gr/~stoug/odep/papers/DATA%20MINING%20FOR%20IMBALANCED%20DATASETS:%20AN%20OVERVIEW.pdf)</sup> 邻域清洗规则（NCL）保留感兴趣类的所有样本，使用Wilson的ENN识别噪声数据，并额外移除那些将少数类样本误分类的多数类邻居，强调清洗甚于缩减。<sup>[13](https://sci2s.ugr.es/keel/pdf/algorithm/congreso/2001-Laurikkala-LNCS.pdf)</sup>

## 变体

选择标准区分了主要变体。<sup>[1](https://imbalanced-learn.org/stable/under_sampling.html)</sup>

- **随机欠采样**随机删除多数类样本；它存在信息丢失的风险，在所有采样方法中时间复杂度最优。<sup>[2](https://link.springer.com/article/10.1186/s40537-025-01119-4)</sup><sup> • </sup><sup>[4](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0271260)</sup>
- **TomekLinks**移除每个跨类最近邻对中的多数类样本（当sampling_strategy='all'时则移除两个样本）。<sup>[1](https://imbalanced-learn.org/stable/under_sampling.html)</sup>
- **ENN及其扩展**训练一个K近邻分类器，若某观测的K个最近邻中任意一个（kind_sel='all'）或大多数（kind_sel='mode'）属于不同类别，则移除该观测；RepeatedEditedNearestNeighbours重复ENN直至满足停止条件，AllKNN每轮将考察的近邻数增加一个。<sup>[1](https://imbalanced-learn.org/stable/under_sampling.html)</sup>
- **CNN**迭代运行1-NN规则：少数类样本作为集合C的种子，被在C上训练的1-NN误分类的多数类样本被加入，结果为压缩集；它对噪声敏感，且找不到最小的一致子集。<sup>[1](https://imbalanced-learn.org/stable/under_sampling.html)</sup><sup> • </sup><sup>[5](https://www.kdd.org/exploration_files/batista.pdf)</sup>
- **单边选择（OSS）**一遍运行CNN，然后移除Tomek连接以消除压缩引入的噪声样本。<sup>[1](https://imbalanced-learn.org/stable/under_sampling.html)</sup>
- **NearMiss**实现三种启发式：NearMiss-1选择到N个最近负样本平均距离最小的正样本，NearMiss-2选择到其N个最远少数类邻居平均距离最小的多数类样本，NearMiss-3先保留每个负样本的M个最近邻，再选择到其N个最近邻平均距离最大的正样本；NearMiss-1对噪声敏感，NearMiss-3可能是受影响最小的版本。<sup>[1](https://imbalanced-learn.org/stable/under_sampling.html)</sup>
- **InstanceHardnessThreshold**通过交叉验证训练分类器，移除预测类概率较低的样本。<sup>[1](https://imbalanced-learn.org/stable/under_sampling.html)</sup>
- **聚类质心**通过将每个多数类样本簇替换为其K-Means质心来对多数类进行欠采样，质心可能是合成点；某些配置则改为选择一个真实的代表性样本。<sup>[14](https://didawiki.cli.di.unipi.it/lib/exe/fetch.php/dm/17_dm2_imbalanced_learning_2024_25.pdf)</sup>

集成式欠采样在欠采样的多数类子集上训练多个学习器。EasyEnsemble从多数类中独立采样若干子集，在每个子集上训练一个AdaBoost学习器并组合输出；BalanceCascade按顺序训练学习器，将当前学习器正确分类的多数类样本从后续考虑中移除。每个子集\( L_{i} \)的规模设为与少数类相等，\( |L_{i}| = |S| \)。<sup>[6](https://cs.nju.edu.cn/zhouzh/zhouzh.files/publication/tsmcb09.pdf)</sup><sup> • </sup><sup>[15](https://ar5iv.labs.arxiv.org/html/1608.06048)</sup> 两种方法取得的AUC、F值和G均值均高于许多现有的类别不平衡方法，当使用相同数量的弱分类器时，训练时间与普通欠采样大致相同。<sup>[6](https://cs.nju.edu.cn/zhouzh/zhouzh.files/publication/tsmcb09.pdf)</sup>

## 应用

凡感兴趣类稀少之处，就会出现不平衡分类：每年约2%的信用卡账户遭到欺诈，美国HIV感染率约为0.4%，磁盘驱动器故障约为每年1%。一篇基于范式的综述使用模拟和信用卡欺诈数据集，将重采样与代价敏感范式和内曼-皮尔逊范式进行比较，展示了重采样技术、基分类器、度量指标与不平衡比例之间的复杂动态。<sup>[16](https://onlinelibrary.wiley.com/doi/10.1002/sam.11538)</sup> 近期的大规模欠采样工作面向计算约束下的欺诈筛查与网络流量分类，所提出的方法提高了真阴性率（等价地，降低了假阳性率），但在真阳性率或假阴性率上没有显著改善。<sup>[17](https://beta.iopscience.iop.org/article/10.1088/2632-2153/ae601c)</sup>

## 局限与替代方案

主要失效模式直接源于其机制。随机欠采样可能丢弃大量数据，使决策边界更难学习并损失性能。<sup>[8](https://machinelearningmastery.com/random-oversampling-and-undersampling-for-imbalanced-classification/)</sup> 被移除的多数类样本可能携带有用信息，这促成了CNN、ENN、Tomek连接与NearMiss等选择性方法。<sup>[18](https://arxiv.org/pdf/2104.02240)</sup> 欠采样还为原本确定性的学习过程引入了非确定性，因为随机子采样增加了方差。<sup>[7](https://www.site.uottawa.ca/~cdrummon/pubs/ICML03.pdf)</sup>

基准证据混杂且依赖度量指标。在《[PLOS One](https://www.edgepedia.org/zh/plos-one)》那项针对31个不平衡数据集、七种采样方法与八种分类器的研究中，采样仅在12.2%的情况下显著改变AUPRC，在10.0%的情况下显著改变AUROC，且更可能降低而非提升性能；在31个数据集中的29个（AUPRC）和30个（AUROC）上，获得最优分类器并不需要采样；欠采样的表现劣于其他采样方法。<sup>[4](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0271260)</sup> 在模拟研究中，当数据复杂度为低或中等时，欠采样方法获得最高排名；在极端复杂度下，过滤方法排名最高；而过采样由于过度泛化问题在所有情形下排名较低。<sup>[19](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0288540)</sup> Batista及其同事使用C4.5和10折交叉验证、以AUC为度量发现，即便采用移除样本的启发式，欠采样方法的表现也不如过采样方法。<sup>[5](https://www.kdd.org/exploration_files/batista.pdf)</sup>

**替代方案。** Barandela及其同事发现，当多数类与少数类的比例小于约10时，对多数类进行适当的欠采样是最佳选择，只有在比例极高时才需要过采样；当过采样不可避免时，他们建议随后清洗训练集，例如使用Wilson编辑法。<sup>[20](https://sci2s.ugr.es/keel/pdf/specific/congreso/barandela_imbalanced_2004.pdf)</sup> 混合方法先应用过采样，再应用欠采样以缓解类别重叠；Batista、Prati与Monard在2004年一项关于平衡方法的研究中提出了SMOTE+Tomek连接与SMOTE+ENN两种混合方法。<sup>[21](https://doi.org/10.1145/1007730.1007735)</sup><sup> • </sup><sup>[2](https://link.springer.com/article/10.1186/s40537-025-01119-4)</sup> 类别加权通过在scikit-learn中设置class_weight='balanced'完全避免重采样，将损失乘以与类规模成反比的权重。<sup>[15](https://ar5iv.labs.arxiv.org/html/1608.06048)</sup> 集成式欠采样以单一平衡集换取在不同多数类子集上训练的多个学习器。<sup>[6](https://cs.nju.edu.cn/zhouzh/zhouzh.files/publication/tsmcb09.pdf)</sup> 没有单一方法能保证在所有情境下都最具竞争力。<sup>[2](https://link.springer.com/article/10.1186/s40537-025-01119-4)</sup>

理论已对重平衡何时有帮助给出了明确回答。Loffredo、Pastore、Cocco与Monasson在高维情形下推导了线性分类器在欠采样与过采样下泛化曲线的精确解析表达式，并表明同时涉及欠采样与过采样的混合策略能带来性能提升。<sup>[22](https://proceedings.mlr.press/v235/loffredo24a.html)</sup> 一种基于最优传输的方法将支持集缩减表述为最小化多数类分布扭曲的瓦瑟斯坦距离优化；模拟表明，它比随机欠采样、NearMiss、Tomek连接与编辑最近邻更好地保留结构特征。<sup>[23](https://doi.org/10.1115/1.4070589)</sup>

## References

1. [Under-sampling, imbalanced-learn User Guide (Version 0.14.2)](https://imbalanced-learn.org/stable/under_sampling.html)
2. [Resampling approaches to handle class imbalance: a review from a data perspective (Journal of Big Data, 2025)](https://link.springer.com/article/10.1186/s40537-025-01119-4)
3. [When is undersampling effective in unbalanced classification tasks? (Dal Pozzolo, Caelen, Bontempi, ECML/PKDD)](https://dalpozz.github.io/static/pdf/ECML_under_v4.pdf)
4. [An empirical evaluation of sampling methods for the classification of imbalanced data (PLOS One)](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0271260)
5. [A Study of the Behavior of Several Methods for Balancing Machine Learning Training Data (Batista et al., SIGKDD Explorations)](https://www.kdd.org/exploration_files/batista.pdf)
6. [Exploratory Undersampling for Class-Imbalance Learning (Liu, Wu & Zhou, IEEE Trans. SMC-B, 2009)](https://cs.nju.edu.cn/zhouzh/zhouzh.files/publication/tsmcb09.pdf)
7. [C4.5, Class Imbalance, and Cost Sensitivity: Why Under-Sampling beats Over-Sampling (Drummond & Holte, ICML 2003)](https://www.site.uottawa.ca/~cdrummon/pubs/ICML03.pdf)
8. [Random Oversampling and Undersampling for Imbalanced Classification (MachineLearningMastery)](https://machinelearningmastery.com/random-oversampling-and-undersampling-for-imbalanced-classification/)
9. [NearMiss API reference, imbalanced-learn 0.14.2](https://imbalanced-learn.org/stable/references/generated/imblearn.under_sampling.NearMiss.html)
10. [P. Hart (1968). The condensed nearest neighbor rule (Corresp.). IEEE Transactions on Information Theory.](https://doi.org/10.1109/tit.1968.1054155)
11. [Dennis L. Wilson (1972). Asymptotic Properties of Nearest Neighbor Rules Using Edited Data. IEEE Transactions on Systems Man and Cybernetics.](https://doi.org/10.1109/tsmc.1972.4309137)
12. [Data Mining for Imbalanced Datasets: An Overview (Chawla, 2004, Data Mining and Knowledge Discovery Handbook)](https://people.iee.ihu.gr/~stoug/odep/papers/DATA%20MINING%20FOR%20IMBALANCED%20DATASETS:%20AN%20OVERVIEW.pdf)
13. [Improving Identification of Difficult Small Classes by Balancing Class Distribution (Laurikkala, 2001, LNCS)](https://sci2s.ugr.es/keel/pdf/algorithm/congreso/2001-Laurikkala-LNCS.pdf)
14. [Data Mining 2, Imbalanced Learning (University of Pisa course slides, 2024/25)](https://didawiki.cli.di.unipi.it/lib/exe/fetch.php/dm/17_dm2_imbalanced_learning_2024_25.pdf)
15. [Survey of resampling techniques for improving classification performance in unbalanced datasets (arXiv:1608.06048)](https://ar5iv.labs.arxiv.org/html/1608.06048)
16. [Imbalanced classification: A paradigm-based review (Wiley, Statistical Analysis and Data Mining)](https://onlinelibrary.wiley.com/doi/10.1002/sam.11538)
17. [Efficient undersampling methods for highly imbalanced big data: PSU-m and PSU-mm](https://beta.iopscience.iop.org/article/10.1088/2632-2153/ae601c)
18. [Empirical study of imbalance methods with modeling algorithms (arXiv 2104.02240)](https://arxiv.org/pdf/2104.02240)
19. [Optimal selection of resampling methods for imbalanced data with high complexity (PLOS One)](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0288540)
20. [The Imbalanced Training Sample Problem: Under or over Sampling? (Barandela et al., LNCS 3138, 2004)](https://sci2s.ugr.es/keel/pdf/specific/congreso/barandela_imbalanced_2004.pdf)
21. [Gustavo E. A. P. A. Batista, Ronaldo C. Prati, Maria Carolina Monard (2004). A study of the behavior of several methods for balancing machine learning training data. ACM SIGKDD Explorations Newsletter.](https://doi.org/10.1145/1007730.1007735)
22. [Restoring balance: principled under/oversampling of data for optimal classification (ICML 2024, PMLR)](https://proceedings.mlr.press/v235/loffredo24a.html)
23. [Sungjun Seo, Mohammad Afrazi, Kooktae Lee (2025). An Optimal Transport-Based Undersampling Technique for Handling Imbalanced Datasets. Journal of Dynamic Systems Measurement and Control.](https://doi.org/10.1115/1.4070589)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods › Supervised, unsupervised, and semi-supervised learning › Supervised learning concepts

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/undersampling-machine-learning

English original: https://www.edgepedia.org/undersampling-machine-learning
