I am 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?
Yes, this is possible. Let's assume binary classification with
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
If Pr = Re
, again all three metrics are identical.