AI GLOSSARY · AI CONCEPTS
Confusion matrix
Definition
A confusion matrix tabulates known versus predicted classes. Entries can be counts, weighted counts or normalized proportions. Binary classification has a 2×2 table; single-label multiclass classification has one row and column per included class.
Also called: confusion matrices, error matrix, confusion matrix machine learning, confusion matrix explained.
In plain language
A confusion matrix is a scorecard that shows how a yes-or-no sorter went wrong, not only how often. Take a spam filter. Some spam is correctly caught, some good mail is wrongly sent to the spam folder, some spam slips through, and some good mail arrives as it should. The table counts each of those four cases separately. That matters because the two kinds of mistake can cost very different things. The limit: the counts depend on the cutoff the filter uses to call something spam, and the table does not tell you which mistake is worse for you. IBM also warns that accuracy on its own can mislead.
Technical definition
In scikit-learn, C[i,j] records actual class i predicted as class j. With binary label order [negative, positive], the cells are [[TN,FP],[FN,TP]]. Other label orders or tools require their own interpretation. Specify weights and normalization. Multilabel evaluation can use one binary confusion matrix per label or sample.
Worked examples in this catalogue
Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.
Skill by Skill Almanac · Illustrative, not executed
split-leakage-check 53/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- A check of train, validation and test files for duplicates, shared groups, time and label leakage, printed as JSON.
- Why it exercises the concept
- Check the test data for leakage before interpreting the confusion matrix. This skill checks the data rather than calculating the matrix.
Skill by Skill Almanac · Illustrative, not executed
llm-eval-test-sets 57/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- The skill builds and validates an eval dataset for any LLM feature, with a checker for duplicates, missing graders, imbalance and leakage.
- Why it exercises the concept
- When an LLM feature sorts items into labels, an eval set with known labels is what a confusion matrix is computed from. The skill checks for imbalance, which affects how the counts should be read. It does not compute the matrix.
Skill by Skill Almanac · Illustrative, not executed
data-analysis-eda 56/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- A fixed exploratory-analysis procedure and CSV profiler that keeps findings descriptive, evidenced and caveated.
- Why it exercises the concept
- Profiling a labelled table shows how many rows are in each class before you read any counts. This skill profiles data; it does not train or score a classifier.
Coding tool · Illustrative, not executed
Claude Code
- What you see
- Claude Code's overview page describes it as an agentic coding tool that reads your codebase, edits files, runs commands, and integrates with your development tools.
- Why it exercises the concept
- A coding agent can run scikit-learn's confusion_matrix on a small table of true and predicted labels, so you can check which axis holds which label for yourself.
How it shows up when you use agents
A confusion matrix appears when you ask a coding agent to evaluate a classifier: a spam filter, a ticket router, or an LLM prompt that labels support messages. The agent prints a small grid of counts. It is the raw material behind the single scores people quote, such as accuracy, precision and recall. Google's accuracy, precision and recall page gives accuracy as correct predictions over all predictions, recall as TP over TP plus FN, and precision as TP over TP plus FP.
What breaks when it is misunderstood. People read the grid with the axes swapped, so false positives and false negatives trade places. They quote one number and skip the grid, which hides the kind of mistake being made. And they compare matrices from different cutoffs as if they came from different models. See Classification and Ground truth.
Next actions. Ask the agent to print the axis labels with the grid. Say which mistake costs more before you pick a cutoff. Check the test file for leakage with split-leakage-check, then compare against the class counts.
Worked example (illustrative)
For label order [0,1], with 1 positive, the synthetic matrix [[981,9],[4,6]] has actual classes in rows and predictions in columns. It represents TN=981, FP=9, FN=4 and TP=6. Reversing label order or transposing axes changes which cell means which. This matrix was checked with scikit-learn on constructed labels; it is not a measured result for any catalog skill.
Common confusions
- False positive versus false negative. Google's example: a false positive is a not-spam email misclassified as spam, and a false negative is a spam email misclassified as not-spam.
- Rows versus columns. In scikit-learn, rows are the known labels and columns are the predicted labels. Do not assume another tool uses the same layout.
- Confusion matrix versus accuracy. Accuracy is one number computed from the matrix. IBM warns it can be misleading on its own.
- Counts versus rates. The raw cells are counts. The normalize option in scikit-learn turns them into proportions of rows, columns or the total, which answer different questions.
Related terms
Terms that mention Confusion matrix
2 terms mention this one
More in AI concepts
Sources
- Classification: Accuracy, recall, precision and related metrics, Google for Developers (Machine Learning Crash Course) (accessed 2026-11-24)
- Classification: Thresholds and the confusion matrix, Google for Developers (Machine Learning Crash Course) (accessed 2026-11-24)
- sklearn.metrics.confusion_matrix, scikit-learn (accessed 2026-11-24)
- What is a confusion matrix?, IBM (accessed 2026-11-24)
Definitions are written by Skill Almanac from these sources and were checked against them on 2026-11-24. Wikipedia is never the only source.
Review record
Last verified
Drafted by Claude (original draft) and Codex (automated revisions); sources and example targets checked by Independent automated source review (OpenAI Codex); not human peer review on 2026-11-24. Last verified .
Change log (5)
- : Independent automated factual/example review completed. Cached US query estimate aligned to receipt; no traffic promise. Final technical gate recorded separately; publication disabled.
- : First version.
- : Verifier pass: applied reviewer corrections to unsupported or misattributed claims.
- : Metric and evaluation conventions corrected; independent exact-version review pending.
- : Automated review completed; approved for the staged public release. Search indexing is controlled by the release configuration.