All courses › Machine Learning and Data Analysis › The confusion matrix

The confusion matrix

A classification model can be wrong in two ways: it can raise a false alarm, or miss something that is there. The confusion matrix counts the four outcomes, and all the usual measures are calculated from these four numbers.

accuracy=TP+TNTP+TN+FP+FN\text{accuracy} = \frac{TP + TN}{TP + TN + FP + FN}accuracy

Symbols

TPTPtrue positive: found what was there
FPFPfalse positive: false alarm
FNFNfalse negative: missed
TNTNtrue negative

Example

TP = 40, FP = 10, FN = 20, TN = 930:

accuracy =970/1000=97 %= 970/1000 = 97\,\%, even though the model misses a third of the positives.

When the classes are imbalanced, accuracy says little. Look at precision and recall instead.
Practise classification and evaluation for free →

← Learning rate · Precision and recall →

Part of Machine Learning and Data Analysis: Classification and evaluation.