Your fraud dataset is 0.5% positive. Walk me through your strategy for handling the imbalance.
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
First, fix the measurement, then the training, and keep the two concerns separate.
Full worked answer with diagram
First, fix the measurement, then the training, and keep the two concerns separate.
Measurement: accuracy and ROC-AUC will both flatter you (see the FPR dilution problem). Use PR-AUC, precision@k sized to the review team's capacity, or recall at a fixed FPR. Establish the cost matrix - a missed fraud might cost 100× a false alarm - because that determines the operating threshold later.
Training-side options:
- Class weights / weighted loss - upweight positives in cross-entropy. Simple, no data distortion, the usual first move.
- Resampling - undersample negatives (cheap, works when negatives are redundant; can discard signal) or oversample positives. SMOTE interpolates synthetic positives in feature space - sensible for low-dimensional tabular data, mostly pointless or harmful for high-dimensional learned representations, and never apply it before splitting or you leak synthetic copies into validation.
- Focal loss (from RetinaNet) - down-weights easy examples by (1−p)^γ so training focuses on hard ones; designed for extreme imbalance in detection.
- Threshold moving - often the most underrated tool: train normally, get calibrated probabilities, then pick the threshold that optimises expected cost. Imbalance doesn't prevent learning a good ranker; it breaks the default 0.5 threshold.
- Reframing - at extreme rarity or with novel attack patterns, anomaly-detection or one-class formulations may beat classification.
Critical subtleties: evaluate on the natural distribution, never a rebalanced one; if you resample or reweight, your output probabilities are biased and must be recalibrated before thresholding; and validate temporally, because fraud patterns drift and adversaries adapt.
Worth sketching. Two separate lanes converging on the threshold is the structure of the answer: fix measurement, fix training, then recalibrate before you pick an operating point.
flowchart TD
A["0.5% positive"] --> B["Fix measurement"]
B --> C["PR-AUC, precision at the<br/>review budget, cost matrix"]
A --> D["Fix training"]
D --> E["Class weights<br/>or focal loss"]
D --> F["Resampling, inside<br/>the training fold only"]
E --> G["Recalibrate: reweighting<br/>biases the probabilities"]
F --> G
C --> H["Threshold on expected cost,<br/>score the natural distribution"]
G --> H
What a good answer covers
- First, fix the measurement, then the training, and keep the two concerns separate
- Measurement: accuracy and ROC-AUC will both flatter you (see the FPR dilution problem)
- Use PR-AUC, precision@k sized to the review team's capacity, or recall at a fixed FPR
- Establish the cost matrix - a missed fraud might cost 100× a false alarm - because that determines the…
- Training-side options: - Class weights / weighted loss - upweight positives in cross-entropy
Key terms: Measurement · Training-side options · Class weights / weighted loss · Resampling · SMOTE · Focal loss · Threshold moving · Reframing · recalibrated
In the glossary: Accuracy · ROC-AUC · PR-AUC · Cross-entropy · Drift
Interviewer follow-ups to expect
You oversampled and now predicted probabilities are inflated - why, and how do you correct them?
When is undersampling actually preferable?
How do delayed fraud labels (chargebacks arriving 60 days later) change your evaluation?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep