Saraswati Stitch needle-and-thread markSaraswati Stitch®
contact@saraswatistitch.comBook a call
← Glossary

Definition

Confusion matrix

A confusion matrix is a table that shows how a classification model performed by counting its true positives, false positives, true negatives and false negatives.

For a yes-or-no model, the matrix has four cells. True positives are cases the model flagged correctly, false positives are cases it flagged wrongly, false negatives are real cases it missed, and true negatives are cases it correctly left alone. Say a spam filter checks 1,000 emails: it catches 90 of 100 spam emails (90 true positives, 10 false negatives) and wrongly flags 20 of 900 genuine ones (20 false positives, 880 true negatives).

Accuracy alone would say 97 percent, which hides the 10 spam emails that got through and the 20 real ones sent to junk. The matrix shows which mistake the model makes, and the cells feed the standard metrics: precision and recall come straight from them, as Google explains in its machine learning course.

For a business, the useful question is which error costs more. A missed fraud case and a wrongly blocked customer have very different costs, so read the matrix with those costs in mind when you evaluate a model.

Related terms

  • Precision and recall: Precision is the share of a model's positive predictions that were correct, and recall is the share of all real positives the model managed to find.
  • Evaluation (evals): An evaluation, or eval, is a repeatable test that measures how well an AI system does its job on real examples, so you can tell whether a change made it better or worse.
  • Supervised learning: Supervised learning is a machine learning method where a model learns from labelled examples, pairs of inputs and correct answers, so it can predict the answer for new inputs it has not seen before.
  • Machine learning: Machine learning is a branch of AI where a system learns patterns from data and improves at a task through examples, instead of being programmed with explicit rules.