How do accuracy, F1 score and ROC-AUC compare as evaluation metrics for a binary classifier, and when is each appropriate, considering threshold dependence, class imbalance and whether each measures ranking quality or decision quality (use a small confusion-matrix example)?
ML systems and evaluation, Classification metrics
Level L3 Intermediate. Length Long. Nature Th+Mat Both.
What's being asked
Whether you can match a metric to the problem instead of reciting definitions, and back the argument with numbers.
Key idea
Accuracy and F1 judge decisions at one threshold; AUC judges the ranking over all thresholds. Accuracy is dominated by the majority class, F1 ignores true negatives and focuses on the positive class, and AUC ignores both the threshold and calibration.
Steps
- Draw the confusion matrix: (true positives), (false positives), (false negatives) and (true negatives). Define precision , recall , and the three metrics.
- Set up an example: 1000 transactions, 50 of them fraud (5%). Model A predicts "not fraud" for everything. Model B has , , , .
- Accuracy: A gets ; B gets . Accuracy prefers the useless model.
- F1: A has , so recall is 0 and F1 . B has and , so F1 . F1 exposes the difference.
- AUC: if A outputs a constant score, its AUC is . B's AUC depends on its scores, not on the threshold that produced the matrix above. AUC answers "does the model rank positives above negatives?", which suits comparing models before a threshold is chosen, or when the operating point will change.
- Summarise: accuracy for roughly balanced classes with similar error costs; F1 when positives are rare, you care about them, and a threshold is fixed (use if precision and recall matter unequally); ROC-AUC for threshold-free comparison of rankers, insensitive to the class ratio (prefer PR-AUC when positives are very rare).
- Close by noting that none of them uses the real error costs. For deployment, choose the threshold that minimises expected cost on validation data.
Common mistakes
- Describing AUC as "accuracy averaged over thresholds". It is a ranking probability, and a high-AUC model can still have badly calibrated scores or a badly chosen threshold.
- Calling F1 "imbalance-proof". It ignores true negatives, and its value changes when the class ratio changes, because precision does.
- Comparing accuracy or F1 of two models at arbitrary thresholds; both metrics move with the threshold.
- Averaging F1 over classes without saying macro or micro.
How long your answer should be
About a page with the worked example; 6–8 minutes in an exam.
Last checked on 4 December 2026.
Read this
Previous in ML systems and evaluation: A weight matrix is stored densely in fp16 (2 bytes per number). To store an unstructured-pruned copy in CSR (compressed sparse row) format you keep, for each non-zero, its fp16 value (2 bytes) and its column index (int32, 4 bytes), plus one int32 row pointer per row plus one. How many bytes does the sparse copy use at 80% and 95% sparsity, and at what sparsity does it break even with the dense copy?
Next in ML systems and evaluation: Your current click-through rate is 10%. How many users per arm does an A/B test need to detect an absolute increase to 11%, with a two-sided significance level of 5% and 80% power?