---
title: 'Confusion matrix'
description: 'A table counting predicted classes against actual classes, including true and false positives and negatives.'
canonical_url: 'https://darkfactory.dev/glossary/confusion-matrix'
markdown_url: 'https://darkfactory.dev/glossary/confusion-matrix.md'
collection: glossary
date_published: '2026-08-03T00:00:00-04:00'
date_modified: '2026-08-26T00:00:00-04:00'
---

# Confusion matrix


## Definition

A confusion matrix is a table of predicted classes against reference classes. For a binary classifier, it contains true positives, false positives, true negatives, and false negatives. For a multi-class problem, each row and column shows which classes the system confuses.

The raw counts matter because a single score can hide the error pattern. From a binary matrix, you can derive accuracy, precision, recall, specificity, false-positive rate, and other metrics. The operational cost still depends on what each kind of error means in the real setting.

Always state which axis is prediction and which is reference, and whether counts are raw or normalized. A transposed or percentage-only matrix can make the same display tell a different story.

## Distinguish it from nearby terms

A scalar metric summarizes one aspect of performance. The confusion matrix preserves error counts by class. It does not show confidence calibration, ranking quality, or performance at thresholds that were not evaluated.

## Check your understanding

A rare-disease classifier has 99 percent accuracy because it predicts every case as negative. Its matrix reveals zero true positives and every actual case as a false negative.

## Related terms

- [Accuracy](https://darkfactory.dev/glossary/accuracy)
- [Precision](https://darkfactory.dev/glossary/precision)
- [Recall](https://darkfactory.dev/glossary/recall)

## Evidence and further reading

- [NIST AI Resource Center Glossary](https://airc.nist.gov/glossary/)
- [Google Machine Learning Glossary](https://developers.google.com/machine-learning/glossary/)
