Visual walkthrough — Accuracy, precision, recall, F1-score
Step 1 — The four boxes (the only raw material)
WHAT. Imagine a classifier that answers one yes/no question per item: "Is this positive?" (positive = the thing we care about — a fraud, a tumour, a spam email). For each item there are exactly two truths (it really is / really isn't positive) and two answers (model says yes / says no). Two times two makes four possible outcomes. We drop every item into one of four boxes.
WHY. Before any fraction, any metric, any "score", there is only counting. Every metric on this page is nothing but a ratio of these box-counts. If you own the four boxes, every formula is just "which boxes go on top, which go on bottom".
PICTURE. Look at Figure s01. The red box is TP — the items we correctly caught. Notice the two diagonal boxes (TP top-left, TN bottom-right) are the correct answers; the off-diagonal boxes (FP, FN) are the two ways to be wrong.

Every symbol below is one of these four numbers. Nothing else exists yet.
Step 2 — Accuracy: how much of the whole bag did we get right?
WHAT. Draw a ring around all four boxes — that is every prediction we ever made. Then shade only the two correct boxes (TP and TN). Accuracy is the shaded area divided by the whole ring.
WHY this ratio and not another? The question accuracy answers is the laziest possible one: "Out of everything, what share did I get right?" It treats a missed tumour and a false alarm as equally bad — one wrong box is one wrong box. That neutrality is its strength (simple) and its flaw (Step 3).
PICTURE. In Figure s02 the whole square is the denominator; the red L-shaped region (the two diagonal boxes) is the numerator.

Step 3 — Why accuracy lies on a lopsided bag (degenerate case)
WHAT. Take an imbalanced world: 990 legitimate transactions, 10 frauds. A do-nothing model answers "legitimate" to everything. Its boxes: TP , FP , FN , TN .
WHY this is a trap. The huge TN box swamps the ratio. Accuracy looks brilliant (99%) while the model catches zero fraud. The degenerate input here is the empty positive prediction — the model never says "yes", so the boxes that matter (TP, FP) are both zero and simply vanish from the picture.
PICTURE. Figure s03: the giant grey TN box dwarfs the tiny red FN sliver of ten missed frauds. Your eye is fooled exactly the way the number is.

The cure is to build metrics that ignore TN entirely. That is Steps 4 and 5. See also Class Imbalance Handling.
Step 4 — Precision: trusting the alarms (a column view)
WHAT. Forget the truth for a moment. Look only at the items the model said were positive — the left column of the box grid (TP on top, FP below). Precision asks: of that column, what fraction was actually right?
WHY a column and not the whole grid? Because precision is about reliability of a "yes". When the spam filter shouts "spam!", precision is the probability it's telling the truth. The denominator is everything we claimed, so TN and FN (things we said "no" to) are irrelevant — they're not in this column.
PICTURE. Figure s04 isolates the left column. The red slice (TP) inside that column is precision.

Step 5 — Recall: catching the real cases (a row view)
WHAT. Now forget the model's answers and look only at items that were actually positive — the top row of the grid (TP on the left, FN on the right). Recall asks: of everything that was truly positive, how much did we catch?
WHY a row instead of the column? Precision reads down the column of predictions; recall reads across the row of reality. Recall is about not missing. When a cancer screen must never let a tumour slip, recall is the metric with teeth. TN and FP live outside this row, so they're ignored.
PICTURE. Figure s05: the same grid, but now the top row is highlighted, and the red slice (TP) inside that row is recall. Notice TP is the shared corner of Step 4's column and this row — precision and recall look at the same hit from two different directions.

Step 6 — Why we need ONE number, and why the average fails
WHAT. Managers want a single score. The obvious idea: average precision and recall with the ordinary (arithmetic) mean . Test it on the "one lucky guess" model above: , .
WHY this is wrong. A model that catches 1% of frauds should not score "about half decent". The arithmetic mean lets a huge rescue a tiny . We want a mean that refuses to be rescued — one that stays close to the smaller value.
PICTURE. Figure s06 plots, for a fixed precision, the arithmetic mean (thin black) versus the score we're about to build (red) as recall slides from 0 to 1. The red curve hugs the floor when recall is small; the black one floats up dishonestly.

Step 7 — The harmonic mean: F1 built from reciprocals
WHAT. Instead of averaging and directly, average their reciprocals and , then flip the result back. That is the harmonic mean. We start from its literal definition:
WHY reciprocals fix everything. A reciprocal is a magnifier of smallness: if , then — a monster that dominates the sum. So the denominator is ruled by whichever of is worst, and F1 collapses toward it. The single small value can no longer be hidden. The on top is just "two things averaged" (it cancels the two reciprocals when both equal, giving F1 ).
Now clean up the reciprocals — step by step, on this page. First add the two fractions in the denominator over a common denominator :
A fraction divided by a fraction flips and multiplies, so:
This is the compact product-over-sum form. Every symbol is earned: (product) up top, (sum) below, a from "two quantities".
From back down to the four boxes. Substitute the column-form and row-form definitions and :
Multiply top and bottom by to sweep the little fractions away:
Every term in the bottom has a common factor of — pull it out and cancel against one upstairs:
Read the final form as a picture: double the red hit box on both top and bottom, then add the two error boxes (FP the false alarms, FN the misses). TN — the box that fooled accuracy in Step 3 — never appears. F1 is blind to it by construction.
PICTURE. Figure s07 shows the F1 surface: F1 as a function of both and . The red ridge runs along the diagonal ; the surface drops steeply toward any edge where one of them is small.

Step 8 — The degenerate corners of F1
WHAT & WHY. Check the boundary inputs so no scenario surprises you:
- No hits at all (TP , any FP, FN): . A model that never lands a real positive scores exactly zero — correct and merciless.
- Perfect (FP , FN , TP ): . No alarms wasted, no case missed.
- Undefined edge (TP FP FN ): the model made no positive predictions and there were no positive cases. Then and are both — genuinely undefined. Convention: report F1 (nothing positive to detect, nothing detected).
These match the intuition: F1 lives in , hits when either half is hopeless and only when both boxes of error are empty.
The one-picture summary
Figure s08 puts it all together: the four boxes at the centre, with accuracy ringing the whole square, precision reading down the left column, recall reading across the top row, and F1 as the red bridge welding column and row together at the shared TP corner — deliberately never touching TN.

Recall Feynman retelling — say it out loud
Every prediction falls into one of four boxes: a hit (TP), a correct pass (TN), a false alarm (FP), or a miss (FN). Accuracy just counts the two correct boxes over all four — fine until one box (TN) grows so huge it hides a useless model. So we throw TN away. Reading down the column of things we shouted "yes" to gives precision — how trustworthy our alarms are. Reading across the row of things that were truly yes gives recall — how many real cases we caught. They meet at the same hit corner but from different directions. To fold them into one honest number we take the harmonic mean: flip both to reciprocals, average, flip back — which cleans up to , and after substituting the box definitions, to . Because a reciprocal blows up small values, whichever of precision or recall is worst dominates — so F1 stays near the weakest link and can't be fooled by a lucky-but-narrow model. Notice TN is nowhere in that final form.
Recall Quick self-test
Which metric ignores TN entirely? ::: Precision, recall, and F1 — all three. Only accuracy uses TN. Why the harmonic mean instead of the arithmetic mean for F1? ::: Reciprocals magnify small values, so F1 is dragged toward the worse of precision/recall and cannot be rescued by one large value. Model gives TP=1, FP=0, FN=99. Precision and recall? ::: Precision , recall . How does become ? ::: Add the reciprocals over to get , then divided by that flips-and-multiplies to . F1 in box form? ::: .
Go deeper: Precision-Recall Curve · Threshold Optimization · ROC Curve and AUC · Cost-Sensitive Learning · back to Accuracy, precision, recall, F1-score.