Skip to content
Machine Learning

What is a confusion matrix?

A table that shows how a classifier's predicted classes compare with the actual classes. For binary classification it is a 2x2 grid of true positives, false positives, true negatives and false negatives; with k classes it is a k × k grid with correct predictions on the diagonal.

datasciencetrivia.com

Card 1 of 276. Answer: A table that shows how a classifier's predicted classes compare with the actual classes. For binary classification it is a 2x2 grid of true positives, false positives, true negatives and false negatives; with k classes it is a k × k grid with correct predictions on the diagonal.

Created by santiviquez

About · Quizzes · History of AI · To suggest new questions or report an error send me a dm.

The longer answer

A confusion matrix is a table counting how a classifier's predicted classes line up with the actual classes. For two classes it is a 2 × 2 grid of true positives, false positives, false negatives and true negatives. With k classes it is k × k, with correct predictions on the diagonal.

Example: an email classifier with classes work, personal and spam is tested on 100 emails; rows are actual classes, columns predicted. The diagonal holds 35, 24 and 28, so accuracy is 87%. The personal row covers 30 emails: 24 correct, 4 called work and 2 called spam, so recall for personal is 24/30 = 0.80. The largest off-diagonal cell shows the worst confusion.

Most classification metrics are ratios of its cells, so interviewers hand you one and ask for precision, recall or specificity. Each decision threshold gives a different matrix, and which error costs more depends on the problem: a missed tumor or a spam false alarm. On imbalanced data, normalize each row to sum to 1.

All questions