Explain precision and recall with an example.
Machine learning basics · Intermediate 2
Short answer
Precision is the share of items you flagged that were truly relevant; recall is the share of all relevant items that you found. A spam filter that flags only obvious spam has high precision but misses some spam, so lower recall. Which matters more depends on the cost of each kind of mistake.
Deeper answer
Precision = true positives / (true positives + false positives). Recall = true positives / (true positives + false negatives). Raising one often lowers the other, which is why F1, their harmonic mean, is used as a single number.
In retrieval for RAG, recall at k asks whether the chunk you needed was in the top k results, and precision asks how much of what you retrieved was useful. Missing the needed chunk (low recall) usually hurts answers more than retrieving a few extra chunks, so teams often tune for recall first, then rerank.
What a strong answer covers
- Precision: share of flagged items that are right
- Recall: share of all relevant items found
- Gives a concrete example
- Which matters depends on the cost of each mistake
Answer it out loud in the mock interview about 1 min
Follow-ups to expect
- In a medical screening test, which matters more and why?
- How do precision and recall apply to RAG retrieval?
Common mistakes
- Swapping the definitions
- Quoting accuracy on a heavily imbalanced dataset
Learn it
- How would you tell whether a new model really performs better in an A/B test?
- Explain the bias-variance trade-off.
- What is the difference between a random forest and gradient boosting?
- How does k-means work, and how do you choose k?
- What is data leakage, and how do you prevent it?
- Give an example of feature engineering that made a model better.
- How do you know whether you have enough training data?
- How do you handle a heavily imbalanced classification problem, such as fraud detection?
- What is the difference between linear and logistic regression?
- How do you deal with missing values in a dataset?
- Walk me through an ML project you did, end to end.
- What is overfitting, and how do you spot it?
- What do L1 and L2 regularisation do?
- What is the difference between supervised and unsupervised learning?
- Why do we split data into training, validation and test sets?
- What is the difference between training and inference?