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 =TP+TNN and F1 =2PRP+R=2TP2TP+FP+FN judge decisions at one threshold; AUC =Pr⁡(s(x+)>s(x−)) 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

  1. Draw the confusion matrix: TP (true positives), FP (false positives), FN (false negatives) and TN (true negatives). Define precision P=TPTP+FP, recall R=TPTP+FN, and the three metrics.
  2. Set up an example: 1000 transactions, 50 of them fraud (5%). Model A predicts "not fraud" for everything. Model B has TP=40, FN=10, FP=60, TN=890.
  3. Accuracy: A gets 950/1000=95%; B gets (40+890)/1000=93%. Accuracy prefers the useless model.
  4. F1: A has TP=0, so recall is 0 and F1 =0. B has P=40/100=0.4 and R=40/50=0.8, so F1 =2×0.4×0.80.4+0.8≈0.533. F1 exposes the difference.
  5. AUC: if A outputs a constant score, its AUC is 0.5. 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.
  6. 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 Fβ 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).
  7. 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

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 1000×1000 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?