Skip to content

Commit

Permalink
F1 calculation
Browse files Browse the repository at this point in the history
return 0 if precision and recall are zero
  • Loading branch information
urialon authored Feb 2, 2022
1 parent f33552e commit e7547de
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tensorflow_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,10 @@ def recall(self):

@property
def f1(self):
return 2 * self.precision * self.recall / (self.precision + self.recall)
if self.precision + self.recall == 0:
return 0
else:
return 2 * self.precision * self.recall / (self.precision + self.recall)


class TopKAccuracyEvaluationMetric:
Expand Down

0 comments on commit e7547de

Please sign in to comment.