Metrics: which one, and when

The classification and regression metrics, what each one hides, and how to choose between them from the cost of being wrong rather than from habit.

The threshold metrics

PrecisionTP ÷ (TP + FP) — of what you flagged, how much was rightThe metric when a false positive is expensive: blocking a legitimate transaction, paging an engineer, deleting a file.
Recall (sensitivity)TP ÷ (TP + FN) — of what was there, how much you foundThe metric when a miss is expensive: a missed tumour, a missed fraud, a missed safety violation.
F12PR ÷ (P + R) — the harmonic meanA convenience when precision and recall matter roughly equally. It encodes a specific and often wrong assumption that they do; if you know the relative costs, use them instead.
Accuracy(TP + TN) ÷ everythingFine at balanced classes, actively misleading otherwise. At a 1% positive rate, predicting 'no' every time scores 99%.
SpecificityTN ÷ (TN + FP) — of the negatives, how many you left aloneRecall's mirror image. Quoted in medical and screening contexts far more than in machine learning, and it is the same quantity as one minus the false positive rate.
Macro versus micro averagemacro weights each class equally; micro weights each example equallyMacro is what you want when rare classes matter. Micro average equals accuracy in single-label multi-class problems, which surprises people.

The ranking metrics

ROC AUCprobability a random positive scores above a random negative · 0.5 is chanceThreshold-free, so it measures the ranking rather than a decision. Insensitive to class balance, which is a virtue when comparing across datasets and a trap when the positive class is rare.
PR AUC (average precision)baseline equals the positive rate, not 0.5Preferred under heavy imbalance. A 0.99 ROC AUC and a 0.35 PR AUC describe the same model at a 1% positive rate, and the second one is the honest number.
Precision at kof the top k you acted on, how many were rightThe right metric whenever capacity is fixed — a review queue, a page of results, an alert budget. Choose k from the real capacity.
Recall at kof everything relevant, how much appeared in the top kThe metric for the retrieval stage of a RAG system, where a reranker gets a second chance but only over what was retrieved.
NDCGranking quality with graded relevance and position discountingUse when results have degrees of relevance rather than being right or wrong, and when position matters. Overkill when relevance is binary.

Probability quality

Calibrationof the cases predicted at 0.7, about 70% should be positiveMatters whenever a downstream decision uses the number itself — expected value, routing, triage. A model can rank perfectly and be badly calibrated.
Expected calibration error (ECE)average gap between confidence and accuracy across binsBin count changes the value, so quote it with the binning. A reliability diagram tells you more than the scalar does.
Brier scoremean squared error of the predicted probability · lower is betterProper scoring rule, so it rewards honest probabilities. Decomposes into calibration and discrimination, which is useful when you want to know which one broke.
Log losspunishes confident wrong answers severelyThe loss you usually train against. Unbounded, so one very confident mistake can dominate the mean on a small eval set.

Regression, and choosing

MAEmean absolute error · in the units of the targetRobust to outliers, and directly interpretable to someone outside the team. Optimising it targets the median.
RMSEroot mean squared error · punishes large misses disproportionatelyUse when a single large error is much worse than several small ones. Optimising it targets the mean, which outliers move.
MAPEmean absolute percentage errorUndefined at zero and asymmetric — it punishes over-prediction more than under-prediction. Common in forecasting and worth replacing with MASE or a scaled error where you can.
Choosing the thresholdwhere expected cost is lowest, not at 0.5If a false negative costs ten times a false positive, act whenever predicted probability exceeds roughly 1/11, not 1/2. This single step improves more systems than model changes do.
Choosing the metricwrite down what each kind of mistake costs, then pick the metric that reflects itThe question 'which metric' is almost always the question 'what happens when we are wrong, and to whom' in disguise.

Figures last checked 2026-09-13. Several of these age; check anything you are about to rely on.

Where these numbers come from