# Confusion Matrix

Original article was published on Artificial Intelligence on Medium

In many fields such as medicine, software engineering and marketing, when a machine learning model is built for a particular purpose, it is important to evaluate the model. One way to evaluate a model is with the use of the confusion matrix.

The variables in the confusion matrix can be tricky. Hence, I’ll attempt to explain in the simplest way possible.

Let’s say we are looking to test for a disease called ‘Acute Syndrome’ (AS).

The variables for the confusion matrix are described within the context of the disease AS:

True Positive (TP): A patient tested positive to AS and they actually have AS.

True Negative (TN): A patient tested negative to AS and they do not have AS. As a patient, this is the best place to be :).

False Positive (FP) (also known as Type 1 error): A patient tested positive to AS but the test result is wrong as the patient does not have AS.

False Negative (FN) (also known as Type 2 error): A patient tested negative to AS but the test result is wrong as the patient actually has AS.

Lets put this into context with some data. We assume that we have a random sample of patients.

1 indicates that a patient has AS, and 0 indicates that a patient does not have AS. Actual and predicted cases are presented below.

actual = [1,1,0,1,0,0,1,0,0,0]

predicted = [1,0,0,1,0,0,1,1,1,0]

The confusion matrix below is dervied from the actual and predicted cases.