SDE & MLE Prep

Handling Class Imbalance

Q: Your positive class is 0.1% of the data. What do you do?

  1. Use the right metric (PR-AUC, recall@precision, not accuracy).
  2. Resample: undersample negatives (fast; re-calibrate probabilities afterwards) or oversample positives / SMOTE.
  3. Class weights in the loss (weight ∝ 1/frequency), or focal loss (down-weights easy examples).
  4. Tune the decision threshold on validation data for the required precision/recall.
  5. Get more positives: active learning, weak labels, data augmentation.
  6. Consider anomaly-detection framing when positives are extremely rare.