AI Evaluation / Foundations
Choosing metrics that track what you actually care about.
Reviewed by Yuvaraj
A metric is your definition of success written in numbers, and a model optimizes exactly what you write down, not what you had in mind. Choose the wrong measure and you can ship something that scores beautifully while failing the people who use it. This lesson is about the decision that comes before any evaluation runs: what, precisely, to measure. We separate the goal from the cheaper stand-ins used in its place, work through the classification metrics and the trap of accuracy on imbalanced data, add the guardrails that quality scores ignore, and confront why good metrics rot the moment you optimize them.
Start by naming the outcome you actually care about, the task metric. For a support assistant it might be the share of conversations a user finishes without escalating to a human; for a fraud system, the money saved minus the cost of false alarms. Task metrics are the truth, but they are usually slow, expensive, or only observable long after the decision was made.
So in practice you optimize a proxy metric: something cheap and immediate that you believe moves with the task metric, a classifier's F1, a thumbs-up rate, an overlap score against a reference answer. The entire validity of an evaluation rests on one question: does the proxy actually track the goal? If it does not, every decision you make from it is confidently wrong.
Ask about this lesson, or about anything in AI. Answers cite the lessons they draw on.
Finished this lesson?
Mark it complete to earn XP, keep your streak, and schedule a review.
Most evaluation failures are not arithmetic errors. They are a correct computation of an invalid proxy.
When the task is a yes/no decision, four counts describe every prediction: true positives (), false positives (), false negatives (), and true negatives (). Every classification metric is a ratio of these four numbers.
Precision and recall pull against each other, so a single summary is convenient. The F1 score is their harmonic mean, which stays low unless both are reasonable:
Accuracy weights every example equally, so it is dominated by whichever class is most common. On imbalanced data, where the interesting class is rare, the majority class alone produces a high score. The base rate, not the model's skill, is doing the work. That is the single most common way a metric lies, and it is worth watching happen in numbers.
A platform flags abusive messages. In a labelled sample of 10,000 messages, 1% are truly abusive, 100 positives and 9,900 negatives. Consider the laziest possible model: it always predicts safe.
| Predicted abusive | Predicted safe | |
|---|---|---|
| Actually abusive | TP = 0 | FN = 100 |
| Actually safe | FP = 0 | TN = 9,900 |
Now compare a genuine detector that flags 150 messages, 70 of them correctly: TP = 70, FP = 80, FN = 30, TN = 9,820. Its precision is , its recall is , and its F1 is .
| Metric | Always-"safe" model | Real detector |
|---|---|---|
| Accuracy | 99.0% | 98.9% |
| Precision | undefined (→ 0) | 0.47 |
| Recall | 0 | 0.70 |
| F1 | 0 | 0.56 |
The useful model has lower accuracy than the useless one, 98.9% against 99.0%, because catching abuse means accepting some false alarms, and every false alarm costs an accuracy point. Accuracy cannot tell these two models apart; it even prefers the wrong one. Precision, recall, and F1 separate them instantly, moving the F1 from to .
Beat the baseline, not zero
Always benchmark a candidate against the majority-class baseline, the model that always predicts the common class. If your headline metric barely moves from that baseline, the metric is measuring the base rate, not your model. Report one that actually moves.
A single quality number, however well chosen, describes only whether the output is good. It says nothing about whether the system is shippable. Production systems optimize a primary quality metric subject to guardrails, secondary metrics that must not regress, even when quality improves.
The pattern is to pick one primary metric to maximize and a small set of guardrails to hold. "Best F1 subject to p95 latency under 800 ms and cost under $2 per 1,000 requests" is a shippable target; "best F1" alone is not.
| Metric | What it captures | Choose it when | Watch out for |
|---|---|---|---|
| Accuracy | Fraction of all predictions correct | Classes are balanced and every error costs alike | Collapses on imbalanced data, the base rate scores high |
| Precision | Share of positive predictions that hold | False alarms are expensive (acting on a flag costs) | Trivially high if you flag almost nothing |
| Recall | Share of true positives you caught | Misses are dangerous (a missed case is costly) | Trivially 1.0 if you flag everything |
| F1 | Harmonic mean of precision and recall | You need one number and both errors matter | Hides which of the two is weak; assumes equal weight |
| Latency (p95) | Tail response time users actually feel | The output is user-facing and interactive | The mean looks fine while the tail is painful |
| Cost per request | Recurring spend from real token counts | High volume, or a tight budget | A quality win can be economically unshippable |
| Violation rate | Fraction of outputs that break a policy | Any user-facing generation | A rare violation can outweigh average quality |
The deepest hazard in choosing a metric is that measuring changes behavior. Goodhart's law, in Marilyn Strathern's crisp phrasing, warns that when a measure becomes a target, it ceases to be a good measure. A proxy is chosen because it correlates with the goal on today's data. The moment you optimize the proxy hard, you push the system into regimes where that correlation no longer holds, you get more of the number and less of the thing it stood in for.
The failure is concrete in AI evaluation:
For a curious beginner
It is teaching to the test. Drill students on last year's exam and their scores rise while their understanding does not. The score was a fine thermometer until you started heating it directly.
How it is actually used
Keep the proxy honest. Re-validate it against the real task metric on fresh data, hold out an evaluation set the optimizer never sees, and pair it with a guardrail that would catch its known failure mode, track response length when optimizing a judge, or the refusal rate when optimizing safety.
The underlying mechanism
You optimize a proxy as a stand-in for the goal ; validity assumes a high . Optimization shifts the distribution toward , a region where the historical correlation need not hold, so in general , and the gap widens with optimization pressure.
Common mistakes
zero_division behavior for the undefined case.