MIP Logo

Confused about the Confusion Matrix? Let’s Clear Things Up with Examples!

This post was originally published on The Data School blog between 2018 and July 2025, before our program was renamed to MIP’s Analytics Career Accelerator. References throughout this article to “The Data School” or “DS” all refer to what is now MIP’s Analytics Career Accelerator. The program, its people, and its commitment to launching outstanding analytics careers remain the same – just under a new name.

If you are having trouble viewing this article, please report it here

Confusion matrix is a table that is used to evaluate the performance of a machine learning model for a classification problem.

In this matrix, TP represents the number of true positive predictions (i.e., the model correctly predicted a positive outcome), TN represents the number of true negative predictions (i.e., the model correctly predicted a negative outcome), The false positive cell represents the number of times the model predicted a positive class, but it was actually a negative class, and the false negative cell represents the number of times the model predicted a negative class, but it was actually a positive class.

Using this confusion matrix, we can calculate various performance metrics such as:

  • Accuracy = (TP + TN) / (TP + TN + FP + FN)
  • Precision = TP / (TP + FP)
  • Recall = TP / (TP + FN)

Precision and recall

In general, precision and recall have different use cases depending on the specific problem and the priorities of the stakeholders.

  • If the cost of a false positive is high, such as in the case of detecting fraud or identifying a dangerous disease, it is often more important to maximize precision. In other words, it is more important to minimize the number of false positives, even if it means sacrificing some true positives. In such cases, a model with high precision can be preferred even if its recall is relatively low.
  • On the other hand, if the cost of a false negative is high, such as in the case of detecting cancer or identifying a security threat, it is often more important to maximize recall. In other words, it is more important to minimize the number of false negatives, even if it means increasing the number of false positives. In such cases, a model with high recall can be preferred even if its precision is relatively low.

It is important to note that precision and recall are typically trade-offs, meaning that improving one metric may lead to a decrease in the other. Therefore, it’s important to consider the specific problem and prioritize the metric that is most important for the stakeholders. In some cases, a balanced approach that seeks to optimize both precision and recall may be required.

 

Share this post