Error rate, precision, precision, recall and F1 score

① Error rate and accuracy

Error rate and accuracy are commonly used performance metrics in classification problems, which are applicable to both binary classification tasks and multi-classification tasks.

  • Error rate (error rate): refers to the proportion of misclassified samples to the total number of samples, that is (number of misclassified samples/total number of samples)

  • Accuracy (accuracy): refers to the proportion of correctly classified samples to the total number of samples, that is (the number of correctly classified/total number of samples)

    Accuracy = 1 − Error Rate Accuracy = 1 - Error Rateprecision=1error rate

② Precision, recall and F1 score

For binary classification problems, the real category and the predicted category can be combined into "true positive", "false positive", "true negative" and "false negative" See the table below for four situations:

  • Total number of samples: TP + FP + TN + FN

  • Precision rate: TP / (TP + FP), indicating whether the score is accurate or not

  • Recall rate: TP / (TP + FN), indicating the incompleteness of the score, also known as "recall rate"

  • F1 score:
    f 1 = 2 ∗ Precision ∗ Recall Precision + Recall f1 = \frac{2 * Precision * Recall}{Precision + Recall}f 1=Precision _ _+recall rate2Precision _ _Recall _

insert image description here

example:

Suppose there are 10 animals, of which 16 are cats and 4 are dogs.
Predict cats based on features.

The model is executed, and the output is 10, 7 cats, and 3 dogs.

sample:

  • Positive examples: samples that belong to this category. cat
  • Negative examples: samples that do not belong to this category. dog

Precision (Precision):

The ratio of the number of correctly retrieved samples to the total number of retrieved samples. That is: TP / (TP + FP).

In this example, 7 cats were retrieved correctly, and a total of 10 animals were retrieved, so Precision = 7 / 10.

Recall rate (Recall):

The ratio of the number of correctly retrieved samples to the number of samples that should have been retrieved. That is: TP / (TP + FN).

In this example, 7 cats were correctly retrieved and 16 should be retrieved, so the Recall = 7 / 16.

Guess you like

Origin blog.csdn.net/wahahaha116/article/details/122311276