What are the main families of techniques for handling class imbalance?
Last updated
Techniques fall into a few families: change the data, change the learning objective, change the decision rule, combine models, and measure correctly. The first step is usually picking the right metric and threshold, since that alone often fixes the problem.
Data-level (resampling):
Oversampling the minority: random duplication,
SMOTE,ADASYN.Undersampling the majority: random undersampling,
NearMiss.Cleaning methods that remove boundary noise: Tomek links,
EditedNearestNeighbours.Hybrid combinations:
SMOTETomek,SMOTEENN.
Algorithm-level (cost-sensitive learning):
Class weights such as
class_weight="balanced"orscale_pos_weightin XGBoost.Modified losses: weighted cross-entropy, focal loss, cost matrices.
Decision-level:
Threshold moving: choose the cutoff from a PR curve or an expected-cost calculation instead of using 0.5.
Probability calibration and prior correction when the train and deploy class ratios differ.
Ensemble methods:
Resampling inside an ensemble:
BalancedRandomForestClassifier,EasyEnsemble,RUSBoost.These cut the variance that a single undersample introduces.
Evaluation:
Use PR-AUC, F1/F-beta, recall at fixed precision, or MCC rather than accuracy.
Use stratified splits and cross-validation.
Problem reframing and data:
Collect more minority data, or apply domain augmentation.
For extreme rarity, treat the task as anomaly or one-class detection.