# Understanding Confusion Matrix

#### Posted on January 17, 2023 by By admin, in Machine Learning | 0

A confusion matrix is a table that is often used to describe the performance of a classification algorithm, such as a machine learning model. Each row of the matrix represents the instances in a predicted class, while each column represents the instances in
an actual class (or vice versa).

For example, let’s say we have a binary classification problem where we are trying to predict whether a patient has a certain disease (positive class) or not (negative class). Our model makes the following predictions:

Actual Positive Actual Negative
Predicted Positive 100 50
Predicted Negative 20 130

In this example, the confusion matrix is telling us that:

• In this example, the confusion matrix is telling us that
• 130 patients were correctly predicted to not have the disease (True Negative)
• 50 patients were incorrectly predicted to have the disease (False Positive)
• 20 patients were incorrectly predicted to not have the disease (False Negative)

From the confusion matrix, we can also compute several performance metrics, such as:

1. Accuracy: the proportion of correct predictions out of all predictions. In this
example, the accuracy is (100+130)/(100+50+20+130) = 0.78
2. Precision: the proportion of true positives out of all positive predictions. In this
example, the precision is 100/(100+50) = 0.67
3. Recall (Sensitivity): the proportion of true positives out of all actual positives. In this
example, the recall is 100/(100+20) = 0.83
4. Specificity: the proportion of true negatives out of all actual negatives. In this
example, the specificity is 130/(50+130) = 0.72
5. F1 Score: the harmonic mean of precision and recall. In this example, the F1 score is
2*(0.67*0.83)/(0.67+0.83) = 0.74

It’s important to note that different problems may have different priorities for these metrics. For example, in a medical diagnosis problem, it may be more important to minimize false negatives (i.e. maximize recall) at the expense of increasing false positives, as missing a disease diagnosis can have serious consequences. On the other hand, in a spam email filtering problem, it may be more important to minimize false positives (i.e. maximize precision) at the expense of increasing false negatives, as marking a legitimate email as spam can be annoying for the user.

In conclusion, a confusion matrix is a useful tool to evaluate the performance of a classification algorithm, as it allows you to compute various performance metrics and understand the trade-offs between them.

Thank You
Utkarsh Soni
Helical IT Solutions

Best Open Source Business Intelligence Software Helical Insight is Here