Skip to main content

Confusion matrix and performance measures

Short answer

A confusion matrix compares actual vs predicted classes. Measures include accuracy, sensitivity (TPR), specificity (TNR), precision, NPV, FPR, FNR, and error rate, calculated from TP, FN, FP, TN.

Describe Confusion Matrix with example. Define Accuracy, Error rate, Sensitivity, Specificity, Precision, Recall, Positive Predictive Value and Negative Predictive Value, TPR, TNR, FPR, FNR of the classifier model.

A confusion matrix (contingency table) summarises the performance of a classifier on test data by comparing actual classes with predicted classes. For two classes (positive = class of interest):

Actual \ PredictedPositiveNegative
PositiveTPFN
NegativeFPTN
  • TP (true positives): positives correctly predicted
  • TN (true negatives): negatives correctly predicted
  • FP (false positives): negatives wrongly predicted positive
  • FN (false negatives): positives wrongly predicted negative

Example (cancer test, 1000 records): TP = 90, FN = 60, FP = 40, TN = 810.

Measures

MeasureFormulaExample
Accuracy(TP + TN)/(TP + TN + FP + FN)900/1000 = 0.90
Error rate(FP + FN)/total = 1 − accuracy0.10
Sensitivity = Recall = TPRTP/(TP + FN)90/150 = 0.60
Specificity = TNRTN/(TN + FP)810/850 = 0.953
Precision = PPVTP/(TP + FP)90/130 = 0.692
NPVTN/(TN + FN)810/870 = 0.931
FPRFP/(FP + TN) = 1 − TNR40/850 = 0.047
FNRFN/(FN + TP) = 1 − TPR60/150 = 0.40

Meaning: accuracy is the overall fraction correct; sensitivity/recall is how many real positives are found; specificity is how many real negatives are found; precision (positive predictive value) is how many predicted positives are really positive; NPV is how many predicted negatives are really negative. Accuracy alone is misleading on imbalanced classes, so sensitivity, specificity and precision are also reported.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Data Mining chapter 3 questions →