Home  >  Article  >  Technology peripherals  >  Use an example to demonstrate how to understand the confusion matrix of a binary class

Use an example to demonstrate how to understand the confusion matrix of a binary class

WBOY
WBOYforward
2024-01-22 14:30:22664browse

Confusion matrix is ​​an evaluation model that helps machine learning engineers better understand model performance. This article takes a binary class imbalanced data set as an example. The test set consists of 60 positive class samples and 40 negative class samples to evaluate the machine learning model.

The binary class data set has only two different categories of data, which can be simply named "positive" and "negative" categories.

Now, to fully understand the confusion matrix for this binary classification problem, we first need to be familiar with the following terminology:

True Positive (TP) is It means that samples belonging to the positive class are correctly classified.

True Negative (TN) means that samples belonging to the negative class are correctly classified.

False Positive (FP) means that samples belonging to the negative class are incorrectly classified as belonging to the positive class.

False Negative (FN) means that samples belonging to the positive class are incorrectly classified as the negative class.

Use an example to demonstrate how to understand the confusion matrix of a binary class

An example of the confusion matrix we can obtain by training the model is shown above for this example dataset.

Adding the numbers in the first column, we see that the total number of samples in the positive class is 45 15 = 60. Add the numbers in the second column to get the number of samples in the negative class, which is 40 in this case. The sum of the numbers in all boxes gives the total number of samples evaluated. Furthermore, the correct categories are the diagonal elements of the matrix - 45 for the positive category and 32 for the negative category.

Now, the model classifies the lower left box as a positive sample, so it is called "FN" because the "negative" predicted by the model is wrong. Similarly, the upper right box is expected to belong to the negative class, but is classified as "positive" by the model. Therefore, they are called "FP". We can evaluate the model more carefully using these four different numbers in the matrix.

The above is the detailed content of Use an example to demonstrate how to understand the confusion matrix of a binary class. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:163.com. If there is any infringement, please contact admin@php.cn delete
Previous article:MSE loss functionNext article:MSE loss function