Learning path: Prepare for ML Engineer Interviews · Step 5 of 13
ML System Design Interview: Fraud Detection for Card Payments, in Eight Steps with Numbers
A full interview answer to "design a fraud detection system for card payments": a do-nothing model at 98.8% accuracy that catches 0 of 71 frauds, a cost metric, a cut-off that moves cost from 7100 to 6610, a 50 ms budget and a rules fallback.
What you will learn
- Answer "design a fraud detection system" through all eight design steps
- Show why accuracy fails at 1.3% fraud and price the mistakes instead
- Explain how the cut-off alone moves the cost, and say what the model still misses
- Size serving against a 50 ms budget and show why a rules fallback removes errors but not risk
Before you start
- The ML System Design Framework
- Why Accuracy Lies: The Confusion Matrix
The question: design a fraud detection system for card payments. We'll take it through the same eight steps from the ML system design framework: goal, metric, data, features, model, serving, monitoring and failure.
If you've built the fraud scorer in the Fraud Scoring series, you have something most candidates don't: you can say "when I built this, here's what I found". One thing to be clear about: the numbers in this article come from a small simulation on synthetic data, and the costs are for illustration. In your interview, use the numbers from your own project.
Step 1: the goal
Think of airport security. Wave everyone through, and the danger walks in. Stop everyone, and nobody catches a flight. Both are terrible. So the goal is: stop fraud without holding up honest customers.
Step 2: the metric
Why not accuracy? In our synthetic data about 1.3 in every 100 payments is fraud. A model that allows every single payment scores 98.8% accuracy. There were 71 frauds in the test set, and it caught zero. So accuracy can't be our metric (see Why Accuracy Lies).
We put a price on each mistake instead. For illustration, one analyst review costs 10 and one missed fraud costs 100:
cost = reviews × 10 + misses × 100
Now the metric is total cost. The method is the same one as in The Cost of Being Wrong.
Step 3: the data
Two things make this data hard. First, fraud is rare: that 1.3 in 100. Second, labels come late. You often find out a payment was fraud only when the customer complains, which can be weeks later, so your freshest data isn't fully labelled yet (When Labels Arrive Weeks Late).
Step 4: the features
Think of a bank teller who remembers how many times this card was used in the last hour. A single payment looks normal; the pattern around it gives it away. So we use things like the amount, a new device, and how often this card has been used lately.
Every one of them has to be ready at the moment the payment comes in, and calculated the same way as in training. That's point-in-time correctness and avoiding training-serving skew.
Step 5: the model and the cut-off
Start simple. In our simulation it's a logistic regression: quick to score and easy to explain.
Here's the part people skip. The model only gives a score; we still have to pick a cut-off.
If we flag nothing, we pay for all 71 misses: 7,100. With the usual cut-off of 0.5 it's 6,920, barely moved. So we pick a better cut-off on separate data, 0.15, and the cost on the test set comes to 6,610. Same model each time; the cut-off alone moved the cost.
Say what it still misses
Be honest about that result. At 0.15 the model flags 31 payments, and 8 of those are fraud. The other 23 are false alarms, honest customers who got held up. And 63 frauds still went straight through.
Worked by hand: 31 reviews × 10 + 63 misses × 100 = 6,610, so the saving is 7,100 − 6,610 = 490.
A saving of 490 out of 7,100 is a weak model, and I'd say so in the interview. Saying what your design still misses is part of the answer, and it's where your own project helps, because you can say what you measured.
Step 6: serving
Think of the checkout till: the answer has to come before the customer gets annoyed. These numbers are for illustration, so in an interview you'd state them as assumptions.
Worked by hand: 10,000,000 payments a day ÷ 86,400 seconds × 3 at peak = about 347 requests a second.
A high score doesn't block the card by itself. It goes to an analyst for review, so a person decides the unclear cases. Serving details are in Fraud Scoring, Part 3.
Steps 7 and 8: monitoring and failure
These two go together. In a small simulation we made about 5% of 5,000 calls fail. With no fallback, every failed call comes back as an error: 240 errors on payments.
Now add a fallback: if the model fails or takes too long, simple rules answer instead. Errors go to zero, and the rules answered 384 calls: the 240 that failed plus 144 that were slow.
But zero errors doesn't mean zero risk. Rules only look at a few simple things, so fraud checks are weaker on those calls. So we watch the share of calls on the rules and alert when it climbs. We also watch the score pattern and, when late labels arrive, the cost again.
Follow-ups and a rubric
- "Fraud doubles next month. What changes?" Pick the cut-off again on fresh data, and check the cost.
- "How would you release a new model safely?" Like a trainee beside a senior: it scores in the background, its calls get compared, and it decides nothing yet. See Shadow, Canary and Rollback.
- "The model is down for an hour. What's your exposure?" Every call goes to the rules, so name what they can't see.
An example rubric, out of 8: four rows (goal and metric, data and features, model and cut-off, serving and failure), each 0 if skipped, 1 if only named, 2 if you put a number on it and said what it costs. Every company scores in its own way.
Recap
| Step | The point to land |
|---|---|
| Metric | Accuracy can't work at this fraud rate, so price the mistakes |
| Data and features | Labels come late; features must be ready at decision time |
| Model | The cut-off moves the cost; say what the model still misses |
| Serving | State the load and the budget as assumptions; send high scores to a person |
| Failure | A fallback removes errors, not risk, so watch its share |
Try it yourself
Answer this same question out loud, all eight steps, using the numbers from your own fraud scoring project.
Related course on Udemy
Machine Learning Engineer: From First Model to ML Engineer
Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (paid course, opens in a new tab)Related posts
The ML Engineer Interview Loop: Five Rounds, What Each One Looks For, and a Simple Rubric
The rounds you go through for one ML engineer job: recruiter screen, coding, ML depth, ML system design and behavioural. What each round looks for, the follow-up it brings, and a four-check rubric for your own answers.
The Answer Framework for Technical Interviews: Five Moves, Scored Out of 24
Good interview answers share one shape: a 30-second answer, the mechanism, the trade-off, the metric and the failure test. Worked on one question about a batch job starving everyone else, with a 24-point example rubric.
From Symptom to Pattern: How to Answer "Which Pattern Would You Use?" in an Interview
Start from what you can see, not from the pattern you know. A four-step rule (symptom, cost, metric and failure test, ship first), a symptom table, one worked answer for 429s at peak, and the trap of using a prompt as a lock.
The ML System Design Framework: Eight Steps, in Order, on a Spam Filter
One repeatable route through any ML system design question: goal, metric, data, features, model, serving, monitoring and failure. Worked on an email spam filter, with the follow-ups and a three-check rubric.