MegaMaester

Artificial Intelligence · Lesson 6

Evaluating a Machine Learning Model

beginner16 min · 13 cards
Start here

Evaluating a Machine Learning Model

Why accuracy misleads on imbalanced data: the accuracy paradox, confusion matrix, precision versus recall, and false positives versus false negatives.

Concept 1 of 10

Why this matters

When a company announces that its model is "95% accurate," it sounds impressive and seems to settle the question. Often it does the opposite. Accuracy — the share of predictions a model gets right — hides everything about which mistakes it makes, and on real data the mistakes are rarely balanced. A fraud detector, a disease screen, and a spam filter all face rare events, and there a lazy model that never spots the rare case can post a dazzling accuracy score while being completely useless. Learning to look past the single headline number, and to ask which errors a model makes and what they cost, is the difference between being reassured by a statistic and actually understanding a system's behaviour. These ideas connect directly to statistics, where the very same trade-offs appear as false positives and false negatives.

Concept 2 of 10

Core concepts

The accuracy paradox

Imagine a disease that affects about 1% of people. A model that simply predicts "healthy" for everyone, always, will be right 99% of the time — 99% accuracy — yet it never catches a single sick patient. Accuracy looks superb precisely because the data is imbalanced: the majority class is so large that ignoring the minority barely dents the score. This is the accuracy paradox, and it is why accuracy alone is meaningless whenever the outcome you care about is rare.

The confusion matrix

To see past accuracy you break results into four boxes. A true positive is a sick patient correctly flagged; a true negative is a healthy person correctly cleared. A false positive is a healthy person wrongly flagged, a false alarm; a false negative is a sick patient the model missed. This four-box table is the confusion matrix, and every richer measure is built from it. The all-healthy model above has zero false positives but a catastrophic pile of false negatives — a fact that plain accuracy completely conceals.

Precision and recall

Two numbers rescue us. Recall asks: of all the truly sick people, what fraction did the model catch? Precision asks: of everyone the model flagged, what fraction were truly sick? They trade off against each other. Flag everyone who so much as coughs and you catch every case, giving high recall, but you drown in false alarms, giving low precision. Flag only the certain cases and your alerts become trustworthy, high precision, but you miss the subtle ones, low recall. Which matters more depends entirely on the cost of each kind of error.

Concept 3 of 10

Worked example

A screening test is run on 1,000 people, 10 of whom truly have a condition. The model flags 18 people. It correctly catches 8 of the 10 sick patients, a recall of 80%, but only 8 of its 18 alarms are genuine, a precision of about 44%. Its accuracy is high — it is right on 988 of 1,000 cases — yet accuracy is the least useful number here. What matters is that it missed 2 real cases and raised 10 false alarms, and whether that balance is acceptable depends entirely on what happens next: a cheap, harmless follow-up test, or an invasive and risky one.

Concept 4 of 10

Counterexample

High precision is not automatically the goal. Consider cancer screening, where a missed case, a false negative, can be fatal, while a false alarm merely leads to a further test. Here recall matters most: you would gladly accept many false positives to avoid missing a single real tumour. Now consider a spam filter. A false positive — a real, important email banished to the spam folder — is far more damaging than a false negative, a spam message that slips into the inbox. Here precision matters most. The same two numbers, opposite priorities, because the costs of the errors are reversed.

Concept 5 of 10

Case study: false positives in mammography screening

Breast cancer screening is a textbook real-world example of these trade-offs. Because the disease is relatively rare in any single screening round, even an accurate test produces many false alarms. A widely cited United States study by Elmore and colleagues, published in 1998, estimated that a woman undergoing ten years of annual mammograms had roughly a 50% chance of at least one false-positive result — a suspicious finding that further testing showed to be harmless. Screening programmes knowingly accept this high false-positive rate because the cost of a false negative, a missed cancer, is judged far graver than the anxiety and follow-up of a false alarm. The balance is not a technical accident but an explicit human judgement about which error is worse.

Concept 6 of 10

Common misconceptions

  • "High accuracy means a good model." On imbalanced data, predicting the majority class alone can score high while being useless.
  • "Precision and recall are the same thing." Precision is about the alarms you raise; recall is about the cases you catch.
  • "You can maximise both at once." Usually they trade off; pushing one up tends to pull the other down.
  • "All mistakes cost the same." A missed cancer and a misfiled spam email are not remotely equal errors.
Concept 7 of 10

Interactive challenge — Cost the Errors

For scenarios like fraud detection and disease screening, decide whether precision or recall should be favoured, then defend your choice by the real cost of each kind of mistake.

Think Like a Maester: Never accept an accuracy figure on its own. Ask which errors the model makes and what each one costs — a single number can hide a model that is right almost always and useful never.

Concept 8 of 10

Knowledge check

  1. Why can a 99%-accurate model be worthless on a rare-disease dataset?
  2. What are the four cells of a confusion matrix?
  3. What is the difference between precision and recall?
  4. Why does a spam filter prioritise precision while cancer screening prioritises recall?
  5. What does the accuracy paradox describe?
Concept 9 of 10

Lesson summary

Accuracy is a single number that quietly hides which mistakes a model makes, and on imbalanced data — where the outcome you care about is rare — it can be high and meaningless at the same time. The confusion matrix breaks results into true and false positives and negatives, and from it come precision, how trustworthy the alarms are, and recall, how many real cases are caught. Because false positives and false negatives usually carry very different costs, evaluating a model means deciding which error you most want to avoid and reading the numbers that reveal it — the same reasoning that underlies false positives and false negatives in statistics.

Quick check

What most clearly distinguishes machine learning from traditional rule-based programming?