Can the Precision, Recall and F1 be the same value?

Viewed 12933

I am currently working on an ML classification problem and I'm computing the Precision, Recall and F1 using the sklearn library's following import and respective code as shown below.

from sklearn.metrics import precision_recall_fscore_support

print(precision_recall_fscore_support(y_test, prob_pos, average='weighted'))

Results

0.8806451612903226, 0.8806451612903226, 0.8806451612903226

Is there a possibility to get the same value for all 3, the precision, recall and F1 for an ML classification problem?

Any clarifications in this regard will be much appreciated.

2 Answers

Yes, this is possible. Let's assume binary classification with

Pr = TP  / (TP + FP); Re = (TP + FN); F1 = 2TP / (2TP + FP + FN)

The trivial solution to Pr = Re = F1 is TP = 0. So we know precision, recall and F1 can have the same value in general. Now, this does not apply to your specific result. If we solve the system of equations, we find another solution: FP = FN. So, if the number of false positives is the same as the number of false negatives, all three metrics have identical values.

For multiclass classification problems we have

F1 = 2 * (Pr * Re) / (Pr + Re)

If Pr = Re, again all three metrics are identical.

Related