KatInterview

Train a Fraud Detector Under Severe Class Imbalance

Machine LearningModel answer
HardModel answerMachine Learningmachine learningclass imbalancefraud detection

Last updated

Design and defend an end-to-end ML system for fraud detection where genuine fraud accounts for less than 0.1% of transactions.

Scenario

You are an ML engineer at a payments platform. The data science team has built a binary classifier to flag fraudulent transactions in real time. The dataset contains 500 million transactions from the past 18 months; only ~0.08% are labeled fraud (roughly 400,000 positive examples). A junior teammate trained an XGBoost model, achieved 99.92% accuracy, and declared the problem solved. Your tech lead asks you to review the work before it ships.

What is expected

Address the following in your response:

  1. Problem framing — Why is accuracy a misleading metric here? What are the business consequences of each error type?
  2. Data strategy — What resampling, weighting, or data-augmentation techniques would you consider, and what are the trade-offs of each?
  3. Modeling choices — Which algorithms or training modifications are best suited to severe imbalance, and why?
  4. Evaluation — Define the metrics you would use, explain the precision-recall trade-off, and specify how you would set the decision threshold.
  5. Deployment & monitoring — How does imbalance affect production monitoring, and what signals would trigger a model refresh?
  6. Common pitfalls — Identify at least three mistakes practitioners frequently make with imbalanced datasets.

You may assume labels are reliable (no label noise) and that you have access to raw transaction features (amount, merchant category, device fingerprint, velocity signals, etc.).

Hints

Hint 1

Start by computing what accuracy a trivially naive model achieves, then use that as a baseline argument against the metric choice.

Hint 2

Think about the asymmetric cost of false negatives (missed fraud) vs. false positives (blocked legitimate transactions) and how that should drive both your loss function and threshold selection.

Hint 3

Data leakage through the time axis is the single most common mistake in fraud modeling — make sure your validation strategy reflects the temporal nature of the data.