MCDMModel EvaluationDiagnostic ToolMath steps

Confusion Matrix

Also known as: Error Matrix, Contingency Table

OriginatorStatistical foundationsYear20th centurySources2Related methods6

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.

Key highlights

  • 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.

Intuition

This section is available to Pro members. Upgrade to Pro

How it works

This section is available to Pro members. Upgrade to Pro

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

Strengths
  • 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.
Limitations
  • 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.

Common pitfalls

This section is available to Pro members. Upgrade to Pro

Applications

This section is available to Pro members. Upgrade to Pro

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

  1. 1.
    Everitt, B. S., & Hothorn, T. (2005). A Handbook of Statistical Analyses Using R. Chapman and Hall/CRC.
  2. 2.
    Fawcett, T. (2006). An introduction to ROC analysis. Pattern Recognition Letters, 27(8), 861-874.

You have read it. What now?

Cite this page

ScholarGate. (2026, June 3). Confusion Matrix. ScholarGate. https://scholargate.app/model-evaluation/confusion-matrix