Decode Confusion Matrix

Rahul Kumar
3 min readJun 9, 2020

When I started working on Machine learning problems, I came across Confusion Matrix to evaluate performance measurement for Classification Problems. Initially, it confused me a lot and I always ended up mixing terms but here is a quick and easy way to remember Confusion Matrix.

This blog aims to answer following questions:

1. How to quickly understand confusion matrix for two class Classification?

2. How to assign True Positive, True Negative, False Positive and False Negative?

So, let’s go and understand !!

How to quickly understand confusion matrix for two class Classification?

Confusion Matrix is a matrix for comparing actual results vs predicted results. This helps us to understand how accurate our predictions are and becomes a performance measurement metric for our classification problems.

Example of a Confusion Matrix
Example of a Confusion Matrix

It’s used to calculate different metrics like Sensitivity,Specificity, Recall,Precision, F-1 score.

But, to understand the above let first understand how to decode the terms True Positive(TP), True Negative (TN), False Positive (FP) and False Negative (FN).

Trick to assign TP, TN, FP and FN

Sometimes, it becomes tricky to understand and assign the True Positive, True Negative, False Positive and False Negative and below can be a simple way to deal with it.

Let’s break the term into two parts -

1. True/False

2. Positive/Negative

Understand and Assign True/False

We can quickly assign True/False with below condition

1. If Actual (Yes) is equal to Predicted (Yes) then its TRUE

2. If Actual (No) is equal to Predicted (No) then its TRUE

3. If Actual (Yes) is equal to Predicted (No) then its FALSE

4. If Actual (No) is equal to Predicted (Yes) then its FALSE

Assign True/False

So, its pretty simple to just match actual and predicted values and assign True and False

Understand and Assign Positive/Negative

For this, we will focus only on the Predicted part.

1. If Predicted (No) then assign Negative

2. If Predicted (Yes) then assign Positive

Assign Positive/Negative

So, you see if you apply the above two logics you will never have to break your head into assigning these terms in your Classification Problems.

And even if you forget, don’t worry!! It’s very easy to recall the method, just follow these 2 steps approach-

1. Start with TRUE/FALSE

2. End with POSITIVE/NEGATIVE

Once you know this you can apply these in calculating and understanding other metrics like Recall, Precision and F-1 Score.

I will explain the above metrics in my next blog.

This is my first blog and if you like it, please support me by giving this post some claps 👏. I am always open for your questions and suggestions. You can share this on Facebook, Linkedin, so someone in need might stumble upon this.

You can reach me at:

LinkedIn : www.linkedin.com/in/rahulkumar-23

--

--

Rahul Kumar

Story-teller/Data Science Enthusiast/Technical blogger “Without data, you are just another person with an opinion” - W. Edwards Deming, Data Scientist