Confusion matrix

A confusion matrix is a table that helps in assessing how good the classification model is. It is used when true values/labels are known. Most beginners in the field of data science feel intimidated by the confusion matrix and think it looks more difficult to comprehend than it really is; let me tell you—it's pretty simple and easy.

Let's understand this by going through an example. Let's say that we have built a classification model that predicts whether a customer would like to buy a certain product or not. To do this, we need to assess the model on unseen data.

There are two classes:

 From this, we have put the matrix together:

What are the inferences we can draw from the preceding matrix at first glance?

The different terms pertaining to the confusion matrix are as follows:

Now, let's talk about a few metrics that are required for the assessment of a classification model: