Explain precision and recall with a real example. When would you favour one over the other?
What the interviewer wants to hear
- Precision: of predicted positives, how many are correct
- Recall: of actual positives, how many were found
- Changing the threshold trades one for the other
- Choice depends on the cost of false positives versus false negatives
Model answer
Precision is the share of predicted positives that are truly positive. Recall is the share of actual positives that the model finds. Take a cancer screening model: recall matters most, because missing a sick patient (a false negative) is very costly, while a false positive only leads to an extra test. For a spam filter, precision matters more, because sending an important email to spam is worse than letting a few spam emails through. Most models output a score, and moving the decision threshold trades precision against recall: a lower threshold catches more positives but adds false alarms. I pick the threshold using validation data and the real business cost of each error type. When I need one balanced number, I use F1 score, and to compare models across thresholds I use the precision-recall curve.
Can you answer it under time pressure?
Take a timed easy round and get scored on every answer.
More easy Machine Learning Engineer questions
- What is overfitting, how do you detect it, and how do you reduce it?
- How does gradient descent work, and what is the role of the learning rate?
- What are the training, validation and test sets used for, and how do you split them?
- Why should you build a simple baseline before a complex model? Give examples of good baselines.
- Explain the bias-variance trade-off and how it guides your choice of model.
- What is an embedding, and how would you use embeddings in a product feature?
- When would you choose a tree-based model like gradient boosting over a linear model, and when not?
- How do you handle missing values in a dataset before training a model?
- Explain in simple terms how self-attention works in a transformer.