Confusion Matrix

Last Updated: July 29, 2026 | By Mihail Sebastian | AI Dictionary

A table sorting a classifier's predictions into true and false positives and negatives – the four counts that precision, recall, and F1 derive from.

What is a Confusion Matrix?

A confusion matrix is a table that compares a classification model’s predictions against the true labels, sorting every prediction into one of four cells: true positive, false positive, true negative, or false negative.

It is the backbone of classification metrics. Precision, recall, the F1 score, accuracy, and the ROC curve are all computed from its four counts, so any serious look at a classifier’s errors starts here.

How a Confusion Matrix Works

Rows hold the actual classes and columns the predicted ones (some libraries flip this; check before reading one).

Predicted positivePredicted negative
Actually positiveTrue positive (TP)False negative (FN)
Actually negativeFalse positive (FP)True negative (TN)

A perfect model puts everything on the diagonal. The two off-diagonal cells are the two distinct ways to be wrong, and they rarely cost the same: a false negative is a miss, a false positive is a false alarm. From the four counts: precision = TP / (TP + FP), recall = TP / (TP + FN), accuracy = (TP + TN) / total.

With more than two classes the matrix grows to N x N, and the off-diagonal cells show exactly which classes the model confuses with which – the pattern the name refers to.

Example of a Confusion Matrix

A spam filter processes 1,000 emails, 200 of them spam:

Predicted spamPredicted not spam
Actual spam17030
Actual not spam20780

Accuracy is 95%, which sounds excellent. The matrix shows what that number hides: 30 spam messages reached inboxes (recall 0.85) and 20 legitimate emails were buried in the spam folder (precision about 0.89).

Whether that trade is acceptable is a judgment about costs, not statistics. The matrix is what makes the judgment possible.

Related AI terms: Precision · Recall · F1 Score · Model Evaluation · Ground Truth

Did you like the Confusion Matrix gist?

Learn about 250+ need-to-know artificial intelligence terms in the AI Dictionary.

Mihail Sebastian — Writes about AI governance, regulation, and the technology behind them. Placeholder bio — replace with a real credential line. About

Read the Governor's Letter

Stay ahead with Governor's Letter, the newsletter delivering expert insights, AI updates, and curated knowledge directly to your inbox.

By subscribing to the Governor's Letter, you consent to receive emails from AI Guv.
We respect your privacy - read our Privacy Policy to learn how we protect your information.

Browse All AI Terms A–Z

Every term in the dictionary, in alphabetical order. Jump to a letter or scroll the full list.

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z