Skip to content
Sign in

What is Confusion Matrix?

A confusion matrix is a table that shows how well a classification model performs by comparing its predictions to the actual labels.

It organizes results into four categories: true positives (correctly predicted positive cases), true negatives (correctly predicted negative cases), false positives (incorrectly predicted positives), and false negatives (incorrectly predicted negatives).

These counts let you calculate key metrics such as accuracy, precision, recall, and F1 score, revealing not just overall correctness but the specific types of errors the model makes.

The matrix works for both binary and multi-class problems and is especially helpful when classes are imbalanced.

Example

A spam filter might produce a matrix showing 900 true negatives (real emails correctly kept), 80 true positives (spam correctly caught), 20 false positives (real emails wrongly sent to spam), and 10 false negatives (spam that reached the inbox).

Why it matters

It gives a clear picture of model errors beyond simple accuracy, which is essential for high-stakes uses like medical diagnosis or fraud detection where different mistakes carry different costs.

Frequently asked questions

They stand for true positive, true negative, false positive, and false negative—the four possible outcomes shown in the matrix.