Week 14 · lesson
Accuracy, Precision, Recall, and Error Cost
Once the confusion counts are visible, common metrics become easier to understand.
Accuracy asks: what fraction of all predictions were correct?
Precision asks: when the model predicted positive, how often was that prediction correct?
Recall asks: of all actual positive cases, how many did the model find?
Each metric answers a different question.
Using the previous example—18 true positives, 70 true negatives, 7 false positives, and 5 false negatives:
- accuracy =
(18 + 70) / 100 = 0.88; - precision =
18 / (18 + 7) = 0.72; - recall =
18 / (18 + 5) ≈ 0.78.
Imagine a second model with 92% accuracy but only 55% recall on the defective class. Saying “92% is better than 88%” skips the decision context. If missed defects are the expensive error, the lower-recall model may be worse for the actual job.
Class imbalance can make accuracy look impressive
Suppose only 1% of examples are positive. A useless model that always predicts negative reaches 99% accuracy while detecting zero positive cases.
This is not a mathematical bug. Accuracy is correctly answering its question. The problem is that the question may be too broad for the evidence we need.
Metrics are measurements, not goals by themselves
A team can optimize a metric and still damage the system if the metric does not match the real decision.
Before selecting a metric, document:
- what counts as positive and negative;
- which error types exist;
- who or what experiences those errors;
- whether classes are balanced;
- what action follows the prediction.
Before moving on
Explain why a model can improve precision while reducing recall. You do not need a formula; describe the change in which predictions the model is willing to call positive.