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:
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:
Accuracy
As to accuracy, it is easy to understand, we can understand it as below:
Precision
Precision amis to positive prediction. We can understand it as follows:
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:
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.