Confusion Matrix

A confusion matrix counts how predicted classes differ from true classes. It is the base table behind many classification metrics.

For binary classification:

Predicted positivePredicted negative
True positive classTPFN
True negative classFPTN

The total number of evaluated examples is:

Derived Quantities

True positive rate, or recall:

False positive rate:

Positive predictive value, or precision:

True negative rate, or specificity:

False negative rate:

Accuracy:

Balanced accuracy:

Balanced accuracy is often more informative than raw accuracy under class imbalance.

Why It Matters

Aggregate metrics hide which error type dominates. In imbalanced problems, a model can have high accuracy while missing most positives or producing too many false positives.

Threshold and Prevalence

The confusion matrix is defined after a decision rule. For a score :

Changing changes TP, FP, TN, and FN. A test-set confusion matrix should use a threshold chosen from validation data or a fixed application rule.

Prevalence changes how errors feel operationally. With rare positives, even a low FPR can produce many false positives:

where is the positive prevalence and is the evaluation size.

Multi-Class Form

For classes, the confusion matrix is:

Rows often represent true classes and columns predicted classes. State the convention because transposed matrices invert the reading of common errors.

Checks

  • Which class is treated as positive?
  • Are classes imbalanced?
  • Is the threshold fixed before test evaluation?
  • Are false positives and false negatives equally costly?
  • Should metrics be reported per class, macro-averaged, or micro-averaged?
  • Does the paper show the confusion matrix or only a single derived metric?