Comparing Models Fairly During Selection
A high accuracy score is rarely the end goal of a machine learning task; the metric should stand in for how the model will actually be used.
Why a High Score Is Not the Goal
Suppose you have trained a classification model and it scores well on the measure you happened to compute first. It is tempting to treat that number as the answer. The source material pushes back on this habit. The end goal of a machine learning task is rarely a model with high accuracy by itself. A model exists to support some decision or action in the real world, and the way you judge the model should reflect that purpose.
What do you think happens?
A model labels every email as legitimate. It is tested on 100 emails: 99 are legitimate and 1 is spam. What accuracy does it score?
Reveal answer
99%. The model gets 99 of the 100 predictions right, so its accuracy is 99%.
Accuracy counts every prediction equally, so the 99 easy legitimate emails dominate the score. The one spam email that was missed barely changes the number, even though missing it may be the failure that matters most.
This section is about that choice. Before you can select or compare models, you have to pick the evaluation metric, which is the scoring function that decides which model looks best. The source's advice is direct: make sure the metric you choose is a good stand-in for what the model will actually be used for. The rest of this article follows one prediction at a time, then uses those mistakes to decide which metric to trust.
Tracing One Email Through a Filter
Take a single email and follow it through a spam filter. Two things determine what happens: what the email really is, and what the filter labels it. Each combination lands in exactly one of four outcomes. Start with an email that really is spam. If the filter labels it as spam, the prediction matches reality and nothing has gone wrong. If the filter labels it as legitimate, the message slipped past the filter.
Now take an email that really is legitimate. If the filter labels it as legitimate, again the prediction matches reality. If the filter labels it as spam, a harmless message has been flagged. Those are the four cells of the picture: a correct flag, a missed spam, a wrongly flagged legitimate message, and a correct pass.
False Positives and False Negatives
A false positive happens when the model predicts the positive category for something that is actually negative. A false negative happens when the model predicts the negative category for something that is actually positive. The two errors are mirror images of each other, but they do not usually carry the same cost.
The same classifier can produce either error, so the useful question is not whether it makes mistakes but which mistake you can better tolerate. For a spam filter, a false positive means an important message may be hidden from someone, while a false negative means one spam message reaches the inbox. For a screening model that flags patients as likely to have a condition, the two errors mean very different things for the person being screened. The consequences differ because the situations differ, and the metric should reflect that difference.
Ten Patients, Two Models
Two screening models on the same ten patients
A screening model labels patients as likely to have a particular condition or not. The test set has ten patients: eight do not have the condition and two do. Two candidate models are compared on the same ten patients. Model A labels one of the two sick patients as sick and misses the other. It labels all eight healthy patients as healthy. Model B labels both sick patients as sick, but it also labels two healthy patients as sick. Which model has the higher accuracy, and what does each model get wrong?
- 1Count Model A's correct predictions
Model A gets one sick patient right (a true positive) and all eight healthy patients right (true negatives). That is 9 correct predictions out of 10.
- 2Identify Model A's error
The one sick patient labeled healthy is a false negative. Model A has no false positives.
- 3Count Model B's correct predictions
Model B gets both sick patients right (two true positives) and six of the eight healthy patients right (six true negatives). That is 8 correct predictions out of 10.
- 4Identify Model B's errors
The two healthy patients labeled sick are false positives. Model B has no false negatives.
- 5Compare on accuracy alone
Model A scores 90% and Model B scores 80%, so accuracy alone prefers Model A.
- 6Compare on the consequences
If missing a sick patient is the serious failure, Model A's single false negative is the costly error, and Model B, which misses no sick patients, may be the better fit even with lower accuracy.
Accuracy ranks Model A first at 90% against 80%, but the ranking reverses if a missed sick patient is the costlier error. The metric must be chosen from the consequences before the winner is named.
| Outcome | Model A | Model B |
|---|---|---|
| True positives (sick, labeled sick) | 1 | 2 |
| False negatives (sick, labeled healthy) | 1 | 0 |
| False positives (healthy, labeled sick) | 0 | 2 |
| True negatives (healthy, labeled healthy) | 8 | 6 |
| Overall accuracy | 90% | 80% |
The same ten patients, counted by outcome for each candidate model
Why Imbalanced Classes Hide Failure
The source notes that in practice classification problems rarely have balanced classes. Balanced classes means the categories appear in roughly equal numbers in the data. When one category dominates, a score computed over all predictions can look impressive while hiding the behavior that matters. The dominant category supplies most of the predictions, so getting it right dominates the overall number.
Return to the 100-email inbox. Ninety-nine emails are legitimate and one is spam. A model that never flags anything as spam gets all 99 legitimate emails right and misses the single spam email. Its overall accuracy is 99%, which sounds excellent, yet the category that matters most, spam, is caught zero times out of one. The overall score has hidden the failure entirely.
Choosing a Metric from the Consequences
The practical step is to work backward from the decision. Start by asking what the model will be used for, then ask which errors would hurt in that setting and how much. Only after that should you choose the metric that scores models. The source's instruction is to make sure you understand what the consequences of false positives and false negatives are, and then pick an evaluation metric accordingly. The order matters: the consequences come first, and the metric follows from them.
Applied to the ten-patient screening scenario, the path leads to a clear answer once the consequences are stated. If a sick patient left unflagged is the serious outcome, the reasoning favors the metric that penalizes missed cases, which points toward Model B despite its lower accuracy. If an unnecessary alarm is the serious outcome, the reasoning favors the metric that penalizes false flags, which points away from Model B. Accuracy alone cannot make this choice, because it treats the two errors as interchangeable.
Mistakes Beginners Make When Comparing Models
Common mistake Picking the metric you computed first
What it looks likeRanking two models by accuracy simply because accuracy was the first number printed.
Why it failsThe metric is supposed to stand in for how the model will be used. A number chosen by convenience says nothing about the decision the model supports.
Do this insteadDescribe the decision and the consequence of each error before choosing the scoring function.
Common mistake Treating the two error types as equal
What it looks likeCalling a false positive and a false negative both just 'a wrong prediction'.
Why it failsThe source notes the two errors are mirror images but usually carry very different consequences.
Do this insteadName each error in the specific situation and ask which one costs more.
Common mistake Trusting an overall score on imbalanced data
What it looks likeA spam model that scores 99% on an inbox with 99 legitimate emails and 1 spam email, while never flagging anything.
Why it failsWhen one category dominates, the overall score can look strong while failing on the category that matters most.
Do this insteadCheck performance on the important category directly, not only the overall score.
Common mistake Comparing models on different test data, which makes their scores impossible to compare fairly
Practice: Pick the Metric
Using the ten-patient screening scenario, Model A has 90% accuracy and misses one sick patient. Model B has 80% accuracy and misses no sick patients but flags two healthy patients. A hospital says that a missed sick patient is far more serious than an unnecessary follow-up test. Which model should be preferred, and why would ranking by accuracy alone lead to the wrong choice?
Hints
- First write down which error the hospital considers costly, using the terms false negative and false positive.
- Compare the consequence of the false negative in Model A with the consequence of the false positives in Model B.
- Accuracy counts both errors the same way, so it cannot reflect the hospital's stated priority.
Key Takeaways from Model Comparison
At a glance
- A high accuracy score is rarely the end goal; the metric should stand in for how the model will actually be used.
- A false positive flags a negative case as positive, and a false negative misses a positive case, and the two often have very different consequences.
- Classification problems rarely have balanced classes, so an overall score can look strong while hiding failure on the category that matters most.
- Work backward from the decision: understand the consequences of each error type first, then choose the evaluation metric that reflects them.