A school coding team creates a simple model to flag photographs that may contain litter. The students are excited to see a colourful confusion matrix, but someone reads the rows as the actual answers when the chart labels say those rows are predictions. Four correct-looking percentages can suddenly describe the wrong question.
A confusion matrix is a table that counts how often a classifier’s predictions agree or disagree with known labels. To read it, identify the positive class, locate the actual and predicted axes, then count true positives, false positives, false negatives and true negatives before calculating any rate. A matrix may be transposed without changing the underlying outcomes; the position of each count is not its meaning.
Did you know that a model can have a high overall accuracy and still miss many of the rare cases it is meant to identify? The denominator you choose explains why. This is a lesson in reading evidence before reaching for a formula, not a claim that a classroom model is ready to operate without supervision.
The first diagnostic: which word names the truth?
Show a student a two-by-two table and ask: ‘Which labels come from a teacher’s checked reference set, and which labels come from the computer?’ If the student cannot say, stop before computing a percentage. In this invented project, actual means the manually checked reference label for each photograph and predicted means the model’s output. The reference labels themselves must have been checked; a dataset called ‘actual’ is not automatically flawless.
The positive class here is ‘litter present’. That decision matters: if positive instead meant ‘litter absent’, the true-positive and false-negative interpretation would change. Never infer which class is positive simply from which square is coloured green.
A worked example with forty labelled photographs
Illustrative numbers, not real pupil results: the class sets aside 40 photographs for checking. The reference contains 12 with litter and 28 without. Of the 12 actual litter photographs, the model flags 9 and misses 3. Of the 28 actual non-litter photographs, the model incorrectly flags 6 and correctly ignores 22.
- True positive (TP) = 9: actual litter, predicted litter.
- False negative (FN) = 3: actual litter, predicted no litter.
- False positive (FP) = 6: actual no litter, predicted litter.
- True negative (TN) = 22: actual no litter, predicted no litter.
Check the reference totals first: actual positives are TP + FN = 9 + 3 = 12, and actual negatives are FP + TN = 6 + 22 = 28. Together, 12 + 28 = 40. Now check predictions: predicted positives are TP + FP = 9 + 6 = 15, and predicted negatives are FN + TN = 3 + 22 = 25. Again 15 + 25 = 40. Two independent sums reduce the chance of silently losing a photograph.
The model’s accuracy is (TP + TN) ÷ total = (9 + 22) ÷ 40 = 31/40 = 77.5%. But accuracy does not tell a parent or teacher which errors occurred. Here it combines 9 correctly flagged images with 22 correctly rejected images.
Precision and recall ask different questions
Precision asks: of everything the model flagged as litter, what proportion truly contained litter? Its denominator is all predicted positives. Precision = TP ÷ (TP + FP) = 9 ÷ 15 = 60%. The remaining 6 of 15 flagged images are false alarms under the assumed reference labels.
Recall asks: of all images that really contained litter, what proportion did the model find? Its denominator is all actual positives. Recall = TP ÷ (TP + FN) = 9 ÷ 12 = 75%. It missed 3 of the 12 reference-positive images. Accuracy 77.5%, precision 60% and recall 75% are simultaneously possible and describe different aspects of the same fictional 40-case test.
An especially useful second check is the confusion-matrix convention documented in Google’s classification learning guide. That guide displays predictions as rows and actual labels as columns. Other charts may arrange these the other way around. The axis labels, not the visual position alone, determine which cell means what.
What changes when a table is turned sideways?
Suppose a teacher redraws the same four counts with actual labels down the rows and predicted labels across the columns. TP is still 9, FN still 3, FP still 6 and TN still 22. The printed location of the 3 and 6 can swap across the off-diagonal. Their meaning does not change: one is a missed actual positive and the other is an incorrectly flagged actual negative.
A useful mistake diagnosis is to ask students to narrate one example before using abbreviations: ‘This photograph really contained litter, but the model said it did not.’ That sentence identifies a false negative without any dependence on table orientation. Narration is a bridge from a confusing diagram to a clear classification decision.
Three traps that make a confident calculation wrong
- Swapping axes: treating a predicted-positive total as an actual-positive total changes the recall denominator to a precision denominator.
- Forgetting class balance: a model that usually says ‘no litter’ can appear accurate when litter is rare, even if it fails at the target task.
- Calling the test set representative: forty photographs from one corridor do not establish performance in every school, light level or camera setting.
Also inspect how the reference labels were assigned. If students disagreed about a partially hidden item, record the disagreement and resolve the rule rather than silently treating the model as the only source of truth. Different error costs call for different decisions: a false alarm may mean an extra human review, while a missed hazard can matter more. One metric does not decide every deployment.
From guided practice to independent interpretation
Stage 1 — name the outcomes aloud
Write four short sentences: ‘actual yes, predicted yes’; ‘actual yes, predicted no’; ‘actual no, predicted yes’; ‘actual no, predicted no’. Match them to TP, FN, FP and TN respectively. Do this before showing a formula sheet.
Stage 2 — change the numbers, not the principle
Use a second invented check of 30 photos: TP = 8, FN = 2, FP = 4, TN = 16. First confirm the total 8 + 2 + 4 + 16 = 30. Then find precision = 8/12 = 66.7% approximately; recall = 8/10 = 80%; accuracy = 24/30 = 80%. Explain why accuracy and recall happen to agree here without being the same measure.
Stage 3 — swap the display
Draw the same 30-photo matrix twice, once with actual labels as rows and once with predicted labels as rows. A correct learner preserves the four outcome counts and all three rates. If the calculated precision changes merely because the table was transposed, the interpretation needs repair.
Stage 4 — ask what evidence is missing
Imagine a chart reports only 90% accuracy. Ask whether you can calculate recall. You cannot: the numbers of actual positives and missed positives are unknown. Learning to say ‘insufficient information’ is a measurable achievement.
A parent, teacher and learner can each do something useful
For a parent, the best question is not ‘Did the AI score 90%?’ but ‘Show me the cases it missed and how you checked the labels.’ For a teacher, ask groups to exchange tables with different axis conventions, check each other’s totals, and correct the precise misinterpretation without assigning a permanent ability label. For a learner, annotate the positive class, the two axes and the denominators on a fresh example, then explain them without notes.
Observe progress through a sequence of unseen matrices: can the learner classify the four outcomes correctly, compute one rate with the correct denominator, and explain which real-world question that rate answers? Record errors separately for axis-reading, arithmetic and interpretation. A single successful rehearsed matrix is not proof of general competence.
Frequently asked questions
Can the actual labels ever be wrong?
Yes. The table assumes the reference labels are reliable, but those can contain human error or ambiguous cases. Review and document labelling decisions rather than declaring the reference infallible.
Why are the rows arranged differently in different textbooks?
There is no universal row orientation across every diagram. Always follow the row and column captions. The definitions of TP, FP, FN and TN remain stable once the positive class and source of truth are defined.
Is recall more important than precision?
It depends on the purpose and cost of errors. A classroom project can compare both and explain the trade-off; it should not choose a threshold without discussing context and checking a suitable dataset.
What if the denominator is zero?
A rate such as TP/(TP + FP) is undefined if the model makes no positive predictions. Do not record it as 0% or 100% without a stated special reporting convention.
Where to continue learning
For the denominator skill, read the Core Aim guide on choosing a denominator in a two-way table. The How Mathematics Works reference develops the difference between a valid calculation and its conditions. Explore the eduKate Education Hub and the diagnosis-first approach in our Clementi Secondary 1 Mathematics teaching reference.
A confusion matrix is not a decorative scoreboard. When a student can say what happened in one case, count the corresponding cases, check both margins and explain what each rate answers, the numbers become evidence rather than a pattern to memorise.