# How to make sense of confusion matrix

Consider a binary classification problem with 0 labels denoting normal and 1 abnormal or rare. The number of instances with 0 classes are more in comparison to 1. In general,

1) Does 0 always refer to positive or a negative depending on what we define as a positive and negative? What if the labels are reversed?

2) Is there a particular order that the confusion matrix if displayed? If the confusion matrix is given as:

1   4
0   5


I got this confusion matrix in Matlab. How do I know that the first row is for class 0 or for class 1?

## 2 Answers

Adding to the answer above,

1. The labeling totally depends on how you define it. You can define 0 as negative or as positive. However, for the sake of understanding and ease of readability, keep it meaningful.
2. The instances that are correctly predicted are given by the diagonal.
Here, '1' is True Negative or for the class labelled as 0 and '5' is True Positive or for the class labelled as 1.

If you find it difficult to interpret by a simple confusion matrix, you could plot it. Check out plotConfusion by MathWorks.

• Thank you for your answer. Say out of 900 test datapoints, 883 are known to be labelled as class 0 and 17 as class 1. Say the classification results from the diagonals in the confusion matrix is 97.9% TP for class 0 and 14.2% for class 1. How do I decide if this is good or bad?Can you please clarify this point? – Srishti M Jun 7 '18 at 16:32
• This is an imbalanced dataset. That is why, it does not look so great for class 1. It considers class 1 as noise. 14.2% is probably like 2 or 3 instances? Try some sampling techniques or try to get more data. Undersampling would not work in your case, as there are only 17 records of minority class. Also, the decision of whether the result is good or bad does not boil down to just the accuracy. There are also other metrics that should be considered in case of an imbalanced classification set like Area under ROC, precision and recall. This is problem specific. – aathiraks Jun 7 '18 at 17:01
• I would suggest you to try other modelling techniques first. Perhaps, the good old powerful Logistic Regression? Also, check AUC curve. If it does not improve the results, check for other sampling techniques. – aathiraks Jun 7 '18 at 17:24
• sorry to sound noisy but I noticed and think there is a typo in point 2 of your answer. 1 is True Positive for class labelled as 0 which is the True Negative for class 1 and 5 is True Positive for class labelled as 1. – Srishti M Jun 12 '18 at 3:12
• By True Negative, I mean class 0 labelled as 0. – aathiraks Jun 12 '18 at 5:28

1) It depends in what you define as positive and negative. Generally, and in particular in medicine, people tend to label $0$ as negatives and $1$ as positives, thus being $1$ the abnormal case. But this is completely arbitraty, you can do as you wish.

2) 0 are always displayed in the first row and column. That is, your model has classified one 0 correctly and 5 ones correctly.

• Thank you for your answer. Say out of 900 test datapoints, 883 are known to be labelled as class 0 and 17 as class 1. Say the classification results from the diagonals in the confusion matrix is 97.9% TP for class 0 and 14.2% for class 1 (again the diagonal). How do I decide if this is good or bad? This aspect is unclear to me. Can you please clarify this point? – Srishti M Jun 7 '18 at 16:33
• It is pretty bad for the class 1. You should perform an oversampling strategy. – David Masip Jun 7 '18 at 16:44