Design a spam email classifier
PremiumML systemEasy
- Text classification
- Precision recall
- Class imbalance
Quick answer
This ML system interview question asks you to design a spam email classifier. Aim for a design that turns data into useful predictions in production, then explain the data, training, serving and monitoring. Interviewers want to see how you frame the problem, measure success and keep the model healthy after launch.
The problem
Design a spam email classifier for a large email service like Gmail: a model that scores every incoming email and moves spam to the spam folder. The hard parts are almost never hiding a real email and keeping up with spammers who change their tactics every week.
Mail has already been through basic sender checks (SPF, DKIM and a blocklist of known bad IP addresses). Your model decides between Inbox and Spam for what is left. Users can click "Report spam" in the inbox and "Not spam" in the spam folder; those clicks are the main source of labels.
What must a spam email classifier do?
- Score every email: Give each incoming email a spam probability before delivery; above the threshold it goes to Spam.
- Learn from users: Turn "Report spam" and "Not spam" clicks into labels, and ship a retrained model at least once a day.
How well must it do it?
- Few false positives: At most 0.01% of legitimate emails may land in Spam; a hidden real email costs far more than a missed spam.
- Fast scoring: Under 50 ms p99 per email so delivery is not delayed.
What scale should you design for?
Use these numbers in your estimates.
The scale numbers unlock with this questionUnlock
Key concepts
- Text classification
- Precision recall
- Class imbalance
- User report labels
- Concept drift
- TF IDF
How you’ll practise
- Problem framing
- Data and labels
- Features and model
- Training and evaluation
- Serving and monitoring
- Wrap-up
Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.
What do interviewers look for?
In any ML system design round.
- Frames the product goal as a clear ML problem
- Defines offline and online success metrics
- Explains where the data and labels come from
- Separates training from serving and keeps features consistent
- Plans for drift, retraining and rollbacks
- Weighs model quality against latency and cost
Questions people ask about this interview question
- Which design type is this question?
- It is an ML system question. You design a spam email classifier and explain your choices the way you would in an interview.
- Is this question asked at entry level?
- It is marked Easy, so it suits engineers who are new to ML system interviews. It is also a good warm-up before harder questions.
- What should I cover first?
- Start with the product goal, how success is measured and what data is available. Agree on scope with the interviewer before you design anything.
- Can I practise it for free?
- It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.
Related questions
Updated · Written by the SevyDevy team