Support investigative journalism — donate to IRE →

Confusion Matrix

noun
Foundational concepts

A confusion matrix puts into perspective how well the classification model did. For binary classifcation, we can think of it like this: - True Positive (TP) — the number of times the model predicted a "positive" outcome and the outcome was "positive" - True Negative (TN) — the number of times the model predicted a "negative" outcome and the outcome was "negative" - False Positive (FP) — the number of times the model predicted a "positive" outcome when it was supposed to be "negative." For stats people - this is a Type 1 Error. - False Negative (FN) - the number of times the model predicted a "negative" outcome when it was supposed to be "positive." For stats people - this is a Type 2 Error.

Accuracy = TP + TN / (TP + TN + FP + FN)

Precision = TP / (TP + FP)

Recall = TP / (TP + FN)

F1 Score = (2 * Precision * Recall) / (Precision + Recall)

A confusion matrix courtesy of Geeks for Geeks
Image courtesy of GeeksforGeeks: Understanding the Confusion Matrix in Machine Learning

A matrix can also be used for classification models with multiple classes. The medium article "Confusion Matrix for Multi-Class Classification" by SadafKauser depicts a matrix used for a model that will depict fruit.

A confusion matrix courtesy of Geeks for Geeks
Image courtesy of Medium Article: Confusion Matrix for Multi-Class Classification by SadafKauser
Entry by Libby Seline
About this glossary — who's behind this site and how you can contribute.