Confusion Matrix
Confusion Matrix (Error Matrix) · Also known as: Error Matrix, Contingency Table
The confusion matrix is a table that displays the counts of true positives, true negatives, false positives, and false negatives. It provides a complete picture of where a classifier makes correct and incorrect predictions, enabling calculation of all other classification metrics.
Read the full method
Sign in with a free account to read this section.
Method map
The neighbourhood of related methods — select a node to explore.
When to use it
Always construct a confusion matrix as the first step in evaluating a classifier. Use it to understand error patterns before selecting specialized metrics. The matrix is essential for imbalanced datasets, multi-class problems, and any situation where you want a complete picture of classifier performance.
Strengths & limitations
- Provides a complete picture of classifier performance with full breakdown of all prediction types.
- Enables calculation of any other classification metric.
- Reveals error patterns and biases that aggregate metrics hide.
- Makes imbalanced dataset issues visible.
- Works for both binary and multi-class classification.
- Can be overwhelming to interpret for problems with many classes.
- Does not itself provide a single performance number for comparison.
- Raw counts depend on test set size, making comparison across different datasets challenging.
- May obscure relationships between metrics if not normalized.
Frequently asked
What is the relationship between the confusion matrix and ROC curves?
The confusion matrix provides the raw data (TP, FP, FN, TN) from which ROC curves are constructed. An ROC curve plots the true positive rate (computed from the confusion matrix) against the false positive rate (also from the matrix) across different decision thresholds. The confusion matrix is for a single threshold; the ROC curve shows performance across all thresholds.
How do I interpret a confusion matrix for multi-class problems?
For multi-class problems, the confusion matrix is NxN where N is the number of classes. Diagonal elements are correct predictions for each class. Off-diagonal elements show which classes are confused with each other. To compute metrics like precision or recall for class i, treat class i as positive and all others as negative.
Should I normalize the confusion matrix?
Yes, for visual inspection and comparison. Normalize by dividing each row by the row sum to show the proportion of actual samples from each class that were predicted in each way. This makes imbalanced datasets easier to interpret visually.
Sources
- Everitt, B. S., & Hothorn, T. (2005). A Handbook of Statistical Analyses Using R. Chapman and Hall/CRC. link ↗
- Fawcett, T. (2006). An introduction to ROC analysis. Pattern Recognition Letters, 27(8), 861-874. DOI: 10.1016/j.patrec.2005.10.010 ↗
How to cite this page
ScholarGate. (2026, June 3). Confusion Matrix (Error Matrix). ScholarGate. https://scholargate.app/en/model-evaluation/confusion-matrix
Which method?
Set this method beside its closest kin and read them side by side — the library lays the books on the table; the choice is yours.
- AccuracyModel Evaluation↔ compare
- Matthews Correlation CoefficientModel Evaluation↔ compare
- PrecisionModel Evaluation↔ compare
- Recall (Sensitivity)Model Evaluation↔ compare
- SpecificityModel Evaluation↔ compare