← All AI/ML articles

The confusion matrix, visualised.

A single accuracy number hides where a classifier goes wrong. The confusion matrix shows every kind of mistake. Click a cell to see exactly which points landed in it.

1. Read the grid2. Score each class3. Price the mistakes
class Aclass Bclass Cring colour = what it was predicted as (mistakes only)
Dot colour is the true class. Background colour is the model's region. Diamonds mark each class centre the model learned.
Rows = actual class, columns = predicted class. Click a cell to highlight its points.
Accuracy0
Macro F10
Weakest recall-
Top confusion-
Behind the scenes · 1

One matrix, one score per class

For any class, treat it as "positive" and everything else as "negative". Its TP is the diagonal cell, its FN is the rest of its row (missed), and its FP is the rest of its column (wrongly claimed). Click a row to inspect that class.

Behind the scenes · 2

Where accuracy hides the problem

Accuracy averages over every sample, so big classes dominate it. Per-class precision and recall expose the small ones. Shrink class B in the lab and watch its bars drop while accuracy barely moves. Click a group of bars to select that class.

precision (column view)recall (row view)

Behind the scenes · 3

Not all mistakes cost the same

Missing a fraud case is rarely as cheap as a false alarm. Set a price for each kind of error on the selected class, then see which way of tilting the model costs least. Each row tilts the model toward one class at the current Strength setting (3 when that slider is at 0). Everything below recalculates from the live matrix whenever you change a cost, the selected class or the strength. Click a row to apply it.

A model with the highest accuracy is not always the cheapest one. Choose the cells you most want to shrink, then tune the model to shrink them.

Experiment

Break it on purpose

Hide a rare class

Make class B only 5% of the data. Accuracy stays high while class B is quietly swallowed by its neighbours.

Blur the classes

Push the overlap to the maximum. The off-diagonal cells fill up as the clusters merge.

Tilt the model

Favour class C strongly. Column C fills with false positives while recall of the others drops.

Check yourself

Three quick questions

Key takeaways

  • Rows are actual, columns are predicted (check the convention, since some libraries flip it). The diagonal holds the correct predictions.
  • Row totals are how many of each class really exist, so recall = diagonal ÷ row total.
  • Column totals are how many times each class was predicted, so precision = diagonal ÷ column total.
  • Off-diagonal cells show which classes get confused with which, something accuracy can never tell you.
  • Mistakes have different prices: weigh the cells by cost, and watch small classes, not just the overall score.
← Back to all articles