Evaluation metrics

Precision/recall, F1, ROC-AUC vs PR-AUC, calibration, and picking thresholds from business costs. Accuracy on a 1:1000 fraud dataset is the canonical trap.

About 26 min read3-question knowledge check

The mental model

A metric is a contract between the model and the business about what "good" means — and like any contract, the fine print decides who gets hurt. The analogy: a smoke detector factory. Accuracy asks "what fraction of all detectors made the right call?" — but 999 of 1000 homes never have a fire, so a detector that never beeps scores 99.9%. Precision asks "when it beeped, was there fire?" (false alarms annoy customers). Recall asks "when there was fire, did it beep?" (misses kill people). The costs are wildly asymmetric, so the single number you optimize must encode that asymmetry — or the optimizer will exploit the gap between what you measured and what you meant.

Why this topic exists: the model does not know your intent, only your metric. Every gap between metric and business cost is a direction the optimizer will happily run in. The canonical trap — 99.9% accuracy on 1:1000 fraud — is not a curiosity; it is what actually happens when a team lets a default metric stand in for a cost model.

The second pillar: a score is not a decision. Models emit continuous scores; businesses execute thresholded actions. Metrics split into ranking quality (ROC-AUC, PR-AUC — how well scores order examples), thresholded quality (precision, recall, F1 — how one operating point performs), and probability quality (calibration, log-loss, Brier — whether 0.8 means 80%). Choosing which family matters is a framing question; confusing them is the most common metrics error in interviews and production alike.

The full lesson continues with 15 more sections
  • Deep dive
  • Internal architecture
  • Real-world use cases
  • Best practices
  • Common mistakes
  • Performance
  • Security
  • Production troubleshooting
  • Advantages & disadvantages
  • Alternatives
  • Interview expectations
  • Interview questions
  • Facts to remember
  • Cheat sheet
  • Quick revision