Dealing with Class Imbalance: Resampling, Weighting, and Ensembles
Class imbalance is a very common problem in practical applications—real-world data is never as high-quality as public datasets, and the number of positive and negative samples is often wildly lopsided. There are three main categories of methods for handling class imbalance: Resampling, Weight balancing, and Ensembles.
Resampling
Resampling goes in two directions: undersampling the class with many samples, or oversampling the class with few samples.

A classic undersampling algorithm is Tomek Links: find the majority-class samples that are closest to minority-class samples and remove them, making the decision boundary clearer. But this trick doesn’t always work—it can also erase subtle decision boundaries and backfire.

A classic oversampling algorithm is SMOTE: first compute the K nearest neighbors of some minority-class sample , randomly pick one neighbor from those K, then randomly generate a new sample on the line segment between and ; repeat until enough new samples have been generated.

Weight balancing
Another category of methods assigns different weights to samples of different classes; the representative example is Focal Loss:
Here handles the positive/negative imbalance—assigning different weights to the losses of positive and negative samples; handles the easy/hard imbalance—the larger is, the smaller the loss for high-confidence “easy samples,” so the loss function focuses more on the hard-to-classify “hard samples.”

Ensembles
There is also ensemble learning. The common Bagging (bootstrap aggregating) samples different subsets of the data to train multiple classifiers, then votes on the results and takes the one with the most votes as the final result—a combination of multiple weak classifiers is often more robust than a single one.

References
- He, Haibo, Ma, Yunqian. Imbalanced Learning: Foundations, Algorithms, and Applications. Wiley, 2013.
- Chawla, Nitesh V., et al. SMOTE: Synthetic Minority Over-sampling Technique. JAIR, 2002.
- Lin, Tsung-Yi, et al. Focal Loss for Dense Object Detection. ICCV, 2017.