Handling Class Imbalance
Q: Your positive class is 0.1% of the data. What do you do?
- Use the right metric (PR-AUC, recall@precision, not accuracy).
- Resample: undersample negatives (fast; re-calibrate probabilities afterwards) or oversample positives / SMOTE.
- Class weights in the loss (
weight ∝ 1/frequency), or focal loss (down-weights easy examples). - Tune the decision threshold on validation data for the required precision/recall.
- Get more positives: active learning, weak labels, data augmentation.
- Consider anomaly-detection framing when positives are extremely rare.