TL;DR: First fix the metric (accuracy is useless; use PR-AUC and precision/recall at a cost-based threshold). Then prefer class weights / cost-sensitive loss (no data thrown away, no leakage risk) over resampling. If you resample, do it inside the cross-validation fold, never before the split, or you leak and inflate your numbers. Often the best lever is the decision threshold, not the data.
How to approach it. Lead with the metric, because evaluating imbalance wrong is the most common mistake and it hides every other one. Then walk the techniques from least to most invasive, naming the tradeoff of each, and call out the resampling leakage trap explicitly. The interviewer is checking whether you reach for the threshold and the loss before you reach for synthetic data.
A strong answer. Fix the metric first. With 1% positives, a model that predicts all-negative scores 99% accuracy and is worthless. Use PR-AUC and report precision/recall at the operating threshold; ROC-AUC also flatters on rare positives because the huge true-negative count keeps the false-positive rate tiny. The "fix" for imbalance is often just choosing the threshold from costs, not touching the data at all.
Techniques, least to most invasive:
| Technique | What it does | When it wins | Cost |
|---|---|---|---|
| Threshold tuning | Pick the cutoff from the FP/FN cost ratio | Almost always try first | None; needs a cost model |
| Class weights / cost-sensitive loss | Up-weight minority errors in the loss | Default for most problems | Can over-focus on hard noise |
| Undersample majority | Drop majority rows | Huge data, cheap iteration | Throws away information |
| Oversample / SMOTE | Duplicate or synthesize minority points | Tiny minority, leakage-safe CV | Synthetic points can be unrealistic |
| Ensemble / anomaly framing | Balanced bagging or one-class | Extreme imbalance (<0.1%) | More plumbing, harder to tune |
My defensible default: class weights plus threshold tuning, evaluated with PR-AUC. Class weights use all the data, add no synthetic artifacts, and carry no leakage risk; most libraries expose class_weight. Reach for SMOTE only with leakage-safe CV and a measured benefit, never as the opening move.
The leakage trap. SMOTE and any resampling must run inside each CV fold on training data only. Resampling before the split interpolates synthetic minority points from real ones, then drops near-copies into both train and validation. Your offline PR-AUC jumps, production does not move, and you have shipped the single most common imbalance bug.
Also: collecting more minority data is often the highest-value fix, and use calibration if a downstream decision consumes the probability, since resampling and class weights both distort predicted scores.
Key takeaways
- Fix the metric (PR-AUC, precision/recall at threshold) before touching the data; accuracy lies under imbalance.
- Class weights beat resampling as a default: all data used, no synthetic points, no leakage.
- Resample inside the CV fold only; before the split it leaks and inflates offline numbers.
- The threshold is a free lever; resampling and weights distort probabilities, so recalibrate if you need true scores.
What interviewers probe next.
- "Class weights vs SMOTE?" Class weights are simpler, leakage-free, and use all data; SMOTE adds synthetic points that can be unrealistic and is easy to misuse. Try weights first.
- "Where exactly does SMOTE leak?" If applied before the train/val split, synthetic minority points (interpolated from real ones) end up in both, so validation sees near-copies of training data.
- "Does oversampling change predicted probabilities?" Yes; it shifts the base rate, so recalibrate (Platt or isotonic) if you need true probabilities.
- "When is none of this needed?" When threshold tuning on a normally-trained model already meets the precision/recall target.
Common mistakes.
- Reporting accuracy and declaring success.
- SMOTE/resampling before the split, inflating offline metrics via leakage.
- Reaching for synthetic oversampling before trying class weights and threshold tuning.
- Forgetting that resampling distorts probabilities, then trusting uncalibrated scores downstream.
