06 · Evaluation and experiments
Classification metrics and thresholds
3 min read
A training pipeline needs evaluation criteria before it can decide whether a candidate is suitable for release. For classification, those criteria begin with the kinds of mistakes the model makes when assigning examples to categories. We will connect those error counts to metrics, then examine how a decision threshold changes their consequences for the application.
Turn the confusion matrix into consequences
A confusion matrix groups predictions according to the observed outcome and whether the model flagged it. A flagged violation is a true positive, a flagged allowed item is a false positive, and a missed violation is a false negative. The remaining allowed items are true negatives, which lets us count each kind of success and mistake separately.
In an illustrative set of 10,000 items containing 200 violations, a model might flag 160 violations and 80 allowed items while missing 40 violations. Precision measures how many flagged items are actual violations, giving 160/240, about 66.7%. Recall measures how many violations were found, giving 160/200, or 80%, while the false-positive rate is 80/9,800, about 0.82%.
If flagged items go to review, the team receives 240 items and finds 160 violations. If flagged items are removed automatically, 80 allowed items are removed. The same predictions have different consequences under those two policies, so the evaluation must name the action.
| Actual | Flagged | Not flagged |
|---|---|---|
| Violation | 160 true positives | 40 false negatives |
| Allowed | 80 false positives | 9,720 true negatives |
Compare models at a meaningful threshold
The threshold is the score boundary at which the application treats a prediction as positive. Lowering it generally flags more examples, increasing both detections and false alarms. Comparing models at an acceptable false-positive rate or review volume ties that choice to the actual workload, whereas a default boundary of 0.5 does not establish that the resulting decisions are appropriate.
ROC-AUC measures how well positives rank above negatives across thresholds. Precision-recall analysis is often especially informative for rare events because precision exposes the effect of many negatives on alerts. Neither summary replaces the actual workload at the selected threshold, and precision-recall metrics change when prevalence changes.
Check calibration when probabilities drive decisions
A model can rank examples well while producing overconfident probabilities. If a group of predictions near 0.8 contains positive outcomes only half the time, treating those scores as 80% risk distorts expected-cost decisions. Reliability plots compare predicted probabilities with observed frequencies, using enough examples to interpret each bin.
Log loss and Brier score evaluate probabilistic predictions, but do not isolate calibration from every other aspect of quality. Fit any calibration step on appropriate held-out data, then test on a separate representative period. Changing traffic prevalence or sampling can alter probability meaning after deployment.
These estimates also need enough examples to be informative, especially when comparing small user segments or correlated observations from the same people. Classification metrics describe decisions about individual examples, but a search or recommendation system must also choose an order for several items. The next topic extends evaluation to that setting by examining retrieval coverage and ranking quality.