mini-module ~25 min no-code try-without-ai classification evaluation

Pilzwanderung, The Four Mistakes

Precision, recall, accuracy, F1. Four numbers arguing about the same basket of mushrooms.

There are old mushroom hunters, and there are bold mushroom hunters, but there are no old, bold mushroom hunters. old saying

Every mushroom in the forest is either food or poison. The forager does not know which is which until they look closer, and even then they can be wrong. The question is not whether the model makes mistakes. It will. The question is which mistakes you are willing to pay for.

Each mushroom carries one of two true labels: edible or poisonous. Your model makes one of two decisions: pick or leave. Two labels times two decisions gives four cells. Almost every classification metric is some way of reading those four numbers.

The four cells

Truth in the forest
Your decision
True positive (TP)
Edible, picked. Dinner.
False positive (FP)
Poisonous, picked. Funeral.
False negative (FN)
Edible, left behind. Hunger.
True negative (TN)
Poisonous, left behind.

Two of these are right. Two are wrong. The two wrong ones have wildly different costs and implications. That gap is where the metrics live.

The four metrics

Each metric compresses those four counts into a single number. Each one answers a different question. Each one is wrong by itself.

Precision

TP TP + FP
Of the mushrooms in your basket, how many are actually safe to eat. If precision is one hundred percent, nothing in the basket will kill you. At fifty percent, your dinner is a deadly coin toss.

Recall

TP TP + FN
Of all the edible mushrooms in the forest, how many you brought home. Low recall means you walked past a lot of edible mushrooms.

Accuracy

TP + TN TP + TN + FP + FN
Of all the mushrooms in the forest, in how many you made the right call. Accuracy treats every decision the same. It does not care whether you missed a dinner or ate a death cap.

F1

2 · TP 2 · TP + FP + FN
The truce between precision and recall. Their harmonic mean, which is a polite way of saying it punishes you for being terrible at either one. A model has to do reasonably well on both, or F1 collapses. F1 ignores TN entirely. The correct skip does not count toward this metric.

Pilzwanderung, the game

Sixty mushrooms grow in the clearing. Thirty are edible, thirty are poisonous. A model has looked at each one and given it a number between zero and one: how confident it is that the mushroom is edible. The two distributions overlap, because nothing in the forest is ever quite that clean.

Your job is the threshold. Pick a number. Every mushroom whose score sits above that line goes into the basket. Drag the slider. Watch the four numbers fight.

Model confidence: how edible the model thinks it is
Threshold 0.50
0.00.51.0
TP
Edible & picked
0
FP
Poisonous & picked
0
FN
Edible & left behind
0
TN
Poisonous & left behind
0
Precision
,
Recall
,
Accuracy
,
F1
,
Move the slider. The forest is waiting.
Two failure modes to try. Push the slider all the way left. You pick everything. Perfect recall. You die. Push it all the way right. You pick nothing. Precision is undefined. Recall is zero. Hungry.

Why accuracy lies

Picture a different forest. Most of what grows there is edible. Ninety-nine mushrooms in a hundred are safe. One is a death cap. A model that says "pick everything" is right ninety-nine percent of the time. Ninety-nine percent accuracy. Standing ovation. The forager eats the basket and dies that evening, because the one poisonous mushroom was in there along with the ninety-nine good ones.

Accuracy
99%
Precision
99%
Recall
100%
Forager status
Dead
One hundred mushrooms. Ninety-nine edible, one death cap. The model says "pick everything." The numbers look like a triumph. The forager does not see breakfast.

Accuracy averages over correct and incorrect decisions without asking what each one costs. When one class is rare, or when one kind of error is much worse than the other, accuracy rewards you for the wrong behaviour. Precision and recall split the question into pieces that can be weighted separately. F1 forces both to be reasonable at once.

F1 and the F-beta family

F1 weights precision and recall equally. Sometimes that is wrong. A mushroom forager fears poison more than hunger, so they care more about precision. A cancer screening test fears the missed tumour more than the false alarm, so it cares more about recall. The F-beta family lets you write down which side you worry about.

F0.5 weights precision twice as much as recall. F2 weights recall twice as much as precision. The number changes. The argument does not. Beta is the dial that tells the metric how scared of poison you are.

And so

There is no single best threshold. There is no single best metric. There is a forest, a basket, and a forager who has to decide how often they are willing to be wrong, and in which direction.

You estimate the costs of error and choose your target metrics accordingly.