Precision, Recall, and F1
Precision is how many of your positive predictions were right; recall is how many of the actual positives you caught. They trade off as you move the decision threshold, and which matters depends on the cost of false positives vs false negatives. F1 is their harmonic mean. On imbalanced data, accuracy lies and these metrics (with PR-AUC) tell the truth. Applied-AI interviews probe them because choosing and tuning the threshold by business cost is a core, constantly-tested skill.
TL;DR: A classifier outputs a score; a threshold turns it into a yes/no. Precision = of the items you flagged positive, how many actually were (false-alarm cost). Recall = of the actual positives, how many you caught (miss cost). They trade off as you move the threshold: raise it for higher precision/lower recall, lower it for the reverse. F1 is their harmonic mean. On imbalanced data accuracy is misleading, so precision, recall, and PR-AUC are what you report, and you choose the threshold by the relative cost of false positives vs false negatives.
The two error costs
Every classification has two ways to be wrong: a false positive (flag something that is not) and a false negative (miss something that is). Precision and recall isolate them:
- Precision = TP / (TP + FP): of your positive predictions, the fraction that are correct. Low precision means many false alarms.
- Recall = TP / (TP + FN): of the true positives, the fraction you found. Low recall means many misses.
Which you optimize depends on the cost asymmetry: a spam filter that hides a real email (false positive) is worse than letting one spam through, so it favors precision; a cancer screen that misses a tumor (false negative) is catastrophic, so it favors recall.
The threshold trade-off
A classifier ranks by score; the threshold decides the cutoff. Raise it and you predict positive only when very confident (precision up, recall down); lower it and you catch more positives but with more false alarms (recall up, precision down). There is no free lunch, you pick the operating point by business cost.
F1, the harmonic mean of precision and recall, summarizes both in one number (harmonic, so it punishes a low value in either). The full picture across thresholds is the precision-recall curve, and PR-AUC summarizes it, the right summary for imbalanced problems.
Why accuracy lies on imbalanced data
If 99% of cases are negative, a model that always predicts "negative" is 99% accurate and completely useless, it catches zero positives. Accuracy hides this; precision and recall expose it. So on imbalanced data (fraud, disease, anomalies), report precision/recall and PR-AUC, not accuracy, and choose the threshold deliberately.
Why interviewers probe this
These metrics, and threshold choice by cost, are tested in nearly every ML conversation because they are where modeling meets the business. A strong answer defines precision and recall in terms of the two error costs, explains the threshold trade-off, and immediately ties the choice to which error is worse for this problem, plus the warning that accuracy misleads on imbalanced data (use PR-AUC). It signals you optimize for the real objective, not a vanity number.
Common misconceptions
- "High accuracy means a good model." On imbalanced data, predicting the majority class is highly accurate and useless; use precision/recall/PR-AUC.
- "Precision and recall are independent." They trade off via the threshold; improving one usually costs the other.
- "F1 is always the right summary." F1 weights precision and recall equally; if one error is costlier, weight accordingly (or report the PR curve).
- "There is one correct threshold." The threshold is a business choice driven by the cost of false positives vs false negatives.
Key takeaways
- Precision is the false-alarm-controlled metric; recall is the miss-controlled metric; they trade off via the threshold.
- Choose the threshold by the relative cost of false positives vs false negatives.
- F1 is their harmonic mean; the PR curve and PR-AUC give the full picture.
- Accuracy misleads on imbalanced data; report precision, recall, and PR-AUC instead.
Check yourself before an interviewer does. Answer from memory first.
Your fraud model is 99% accurate on data that's 99% legitimate transactions. Is it any good?
