An Introduction to Accuracy, Precision, Recall & F1-Score in Machine Learning – Machine Learning Tutorial

By | January 11, 2022

Accuracy, Precision, Recall & F1-Score are widely used in machine learning. In this tutorial, we will discuss how to compute them.

In order to understand them easily, we should notice a confusion matrix.

For example:

confusion matrix in accuracy precision recall and f1-score

Here:

TP (True Positive): positive samples are predicted to positive correctly.

FN (False Positive): positive samples are predicted to negative wrongly.

FP (Fasle Negative): negative samples are predicted to postive wrongly.

TN (True Negative): negative samples are predicted to negative correctly.

Accuracy, Precision, Recall & F1-Score can be computed as follows:

how to compute accuracy precision recall and f1-score in machine learning

Accuracy

As to accuracy, it is easy to understand, we can understand it as below:

how to compute accuracy in machine learning

Precision

Precision amis to positive prediction. We can understand it as follows:

how to compute precision in machine learning

It is computed as:

TP / (TP + negative samples are predicted to positive wrongly)

We can find:

Precision determines the ability to classify negative samples.

Recall

Recall can be understand as follows:

how to compute recall in machine learning

Recall can be computed as:

TP / (TP + positive samples are predicted to negative wrongly)

We can find:

Recall determines the ability to classify positive samples.

When use Precision and Recall?

If the negative samples are important, we should focus on precision. Otherwise, we should focus on recall.

However, as to F1-score, the value higher, the model is better.

Leave a Reply