Judging a model
Why the loss is not the metric you care about
Training drives down the lossloss functionA single number measuring how wrong the model's predictions are on a batch of data. Training works by adjusting the model to make this number smaller.See in glossary →, but the loss was chosen to give gradient descent a useful slope, not because it is necessarily the number you care about in the real world. What you care about is a metricmetricA measurement used to judge whether a model succeeds at the real task — such as accuracy, recall, response time, or cost. It need not be the same number used as the training loss.See in glossary →: a measurement of success, such as whether the fraud detector catches fraud or the tumor screen misses cancers. The loss is the handle we turn; the metric is the outcome we’re paid for. This section is about measuring what matters, and why the obvious metric often lies.
Accuracy, and how it fools you
For classificationclassificationA prediction task whose answer is one of a fixed set of categories (spam / not spam, or which of 100,000 tokens comes next). The model outputs a probability per option and is scored with cross-entropy.See in glossary →, the instinctive metric is accuracyaccuracyThe fraction of predictions that are correct. Simple, but misleading on imbalanced data where one class dominates.See in glossary →: the fraction of predictions that are correct. Balanced classes remove one common way accuracy can mislead, but they do not make it automatically appropriate. You may still care about unequal costs for different mistakes, results for particular groups, or whether a 70% confidence score is right about 70% of the time. Class imbalance makes the most obvious failure especially stark.
Imagine fraud that occurs in 1% of transactions. A model that flags nothing (a single line of code that always says “legit”) is 99% accurate. It is also completely useless: it catches zero fraud. High accuracy, zero value. On imbalanced data, accuracy mostly measures how common the majority class is, not whether the model learned anything.
Precision and recall: two ways to be right
To see past accuracy, break predictions into four boxes: the confusion matrixconfusion matrixThe 2×2 table of true/false positives and negatives that summarizes a classifier's outcomes and from which accuracy, precision, and recall are computed.See in glossary →. For a positive class (say “fraud”):
- True positive (TP): flagged, and really fraud.
- False positive (FP): flagged, but actually legit (a false alarm).
- False negative (FN): not flagged, but really fraud (a miss).
- True negative (TN): not flagged, and really legit.
From these come two metrics that pull in different directions:
PrecisionprecisionOf the cases the model flagged positive, the fraction that truly are positive: TP / (TP + FP). High precision = few false alarms.See in glossary → asks: of everything I flagged, how much was right? (Low precision = crying wolf.) RecallrecallOf all truly positive cases, the fraction the model caught: TP / (TP + FN). High recall = few misses. Usually traded against precision.See in glossary → asks: of all the real fraud, how much did I catch? (Low recall = fraud slips through.) A classifier usually outputs a score, and you set a threshold to turn scores into decisions. That threshold trades precision against recall.
Drag the threshold. Raise it and you flag only the highest-confidence cases: precision usually improves, but recall drops as real fraud sneaks under the bar. Lower it and you catch nearly all the fraud (high recall) at the cost of more false alarms (often lower precision). There is no free lunch, only a choice.
The point
The loss got the model trained. But judging it means choosing a metric that mirrors the real cost of being wrong, reading the confusion matrix instead of a single accuracy number, and setting the threshold where the trade-off lands right for your problem. A model isn’t “good” in the abstract. It’s good for a purpose, measured the way that purpose demands.
We now have the whole machine: data, model, loss, gradients, the training loop, generalization, and a clear-eyed way to score the result. Before we spend it on language, let’s step back and see how the field stumbled, stalled, and finally arrived here.