avatarAmit Chauhan

Summary

The webpage provides an in-depth explanation of the confusion matrix, a critical evaluation metric in machine learning for assessing classification model performance, and discusses related statistical measures such as accuracy, precision, recall, false omission rate, F1-score, and the Matthews correlation coefficient (MCC).

Abstract

The article titled "Confusion Matrix in Machine Learning" delves into the significance of the confusion matrix as a classification metric in supervised learning. It illustrates how the matrix, despite its name, serves as a clear visualization tool to understand the performance of a machine learning model by categorizing predictions into true positives (TP), false positives (FP), false negatives (FN), and true negatives (TN). The author emphasizes the importance of these categories in determining Type 1 and Type 2 errors, which are crucial for understanding the model's predictive accuracy and the implications of misclassification. Furthermore, the article explains other key performance indicators such as precision, recall, false omission rate, and the F1-score, highlighting their formulas and relevance in different business contexts. especially where class imbalance is a concern. The Matthews correlation coefficient (MCC) is also presented as a robust measure for binary classification problems. The author concludes by inviting readers to engage with them on LinkedIn and Twitter and provides a list of recommended articles for further reading on related data science topics.

Opinions

  • The author believes that the term "confusion" in the confusion matrix reflects the machine's inability to classify perfectly, indicating a nuanced understanding of model predictions beyond simple accuracy.
  • The article suggests that the confusion matrix offers "fruitful information" about model performance, implying its essential role in model evaluation.
  • The author expresses a preference for the F1-score over other metrics in scenarios involving imbalanced classes, indicating its practical utility in real-world applications.
  • By presenting the MCC, the author conveys that it is a valuable metric for assessing the quality of binary classifications, acknowledging its comprehensive nature in capturing both precision and recall.
  • The inclusion of a list of recommended articles at the end of the webpage suggests the author's view that continuous learning and exploration of related topics are important for data science professionals.

Confusion Matrix in Machine Learning

Classification metric in supervised learning

Confusion Matrix. A photo by Author

Why this metric named as confusion matrix? From my point of view, the matrix term refers to row and column, the confusion term refers to the thought of the machine that didn’t classify 100% accurately. Let’s learn about the confusion matrix a little deeper in this article. It is a combined metric of classification to visualize the performance of the model.

The topics we will cover in this article are shown below:

  • Confusion matrix
  • Type 1 and Type 2 Error
  • Accuracy
  • Precision
  • Recall
  • False omission rate
  • F1-score
  • MCC or phi coefficient

Confusion Matrix

The confusion matrix gives very fruitful information about the predicted performance of the estimator or model that use in machine learning. Let’s see a confusion matrix.

Confusion matrix. A photo by Author

What is inside the confusion matrix? So much information.

Actual values are true binary values “0” and”1". The prediction value that comes after fitting the model is also confusing because it is not predicted all values properly. So, these four terms are born to know the evaluation performance.

  • TP is a true positive value means the predicted value is the same as the actual value.
  • FP is a false positive value means the actual value is “0” but it predicted “1”.
  • FN is a false negative value means the actual value is “1” but it predicted “0”.
  • TN is a true negative value means the actual value is “0” and the model predicted it the same also.

Type 1 and Type 2 Error

These two type error comes when the model does not predict all the data point accurately and some of the points are misclassified that leads to some error.

  • Type 1 error: This error occurs when the actual value is “0” but it predicted “1”. In statistics term, this error tells the level of significance (α) i.e. alpha. The value of alpha is chosen by us so, the error depends on what value we choose.
  • Type 2 error: This error occurs when the actual value is “1” but it is predicted “0”. In statistics term, this error named is beta and it is mainly dependent on the sample size(n) and variance(σ).
Type 1 and Type 2 errors. A photo by Author

Accuracy

It is defined as the closeness or exact of predicted value to the actual value.

Formula:

Accuracy = (TP + TN)/(TP + TN + FP + FN)

Precision

Precision is defined based on true positive values only out of all positive values.

Formula:

Precision = TP/(TP + FP)

Recall

It is also known as sensitivity or hit rate or true positive rate. It tells that how good our estimator or model to predict the positive values.

Formula:

Recall = TP/(TP + FN)

False omission rate

The false omission rate is defined as the occurrence of false-negative values to total negative values predicted as false and true.

Formula:

FOR = FN/(FN + TN)

F1-score

This score is also a harmonic mean of precision and recall. The F1 score tells the accuracy in terms of precision and recall. When we were reading about the central tendency article the harmonic mean is usually use for outliers. Well, this score is more suitable for the business problem which has more dispersion. It is useful in imbalanced classes.

F1 score is more important in terms of false negative and true negative values.

Formula:

F1-score = 2*precision*recall/(precision+recall)

MCC or phi coefficient

This metric is useful in machine learning to know the performance quality in binary classes. The MCC stands for the Mathews correlation coefficient.

Formula:

MCC score

I hope you like the article. Reach me on my LinkedIn and twitter.

Recommended Articles

  1. NLP — Zero to Hero with Python

2. Python Data Structures Data-types and Objects

3. MySQL: Zero to Hero

4. Basics of Time Series with Python

5. NumPy: Zero to Hero with Python

6. Fundamentals of series and Data Frame in Pandas with python

Technology
Artificial Intelligence
Programming
Data Science
Machine Learning
Recommended from ReadMedium