A confusion matrix is a table used to evaluate the performance of a classification algorithm. It shows the counts of true positive, true negative, false positive, and false negative predictions.

Structure

Predicted PositivePredicted Negative
Actual PositiveTrue Positive (TP)False Negative (FN)
Actual NegativeFalse Positive (FP)True Negative (TN)

Key Metrics Derived

From the four cells you can derive the standard classification metrics:

  • Accuracy = (TP + TN) / (TP + TN + FP + FN)
  • Precision = TP / (TP + FP)
  • Recall (Sensitivity) = TP / (TP + FN)
  • Specificity = TN / (TN + FP)
  • F1 Score = 2 × (Precision × Recall) / (Precision + Recall)

Use Cases

  • Evaluating binary and multi-class classification models
  • Understanding model errors and bias
  • Comparing different models