From 4ccaad2ff0274d74394af9a0d15b03bbc84ba2c8 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Mon, 10 Jun 2019 16:55:23 +0200 Subject: [PATCH] Prevented division by zero errors Signed-off-by: Jim Martens --- src/twomartens/masterthesis/evaluate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/twomartens/masterthesis/evaluate.py b/src/twomartens/masterthesis/evaluate.py index 070b9b1..282a15d 100644 --- a/src/twomartens/masterthesis/evaluate.py +++ b/src/twomartens/masterthesis/evaluate.py @@ -296,7 +296,7 @@ def get_f1_score(cumulative_precisions: List[np.ndarray], if not np.count_nonzero(cumulative_precision + cumulative_recall): cumulative_f1_scores.append([]) continue - f1_score = 2 * ((cumulative_precision * cumulative_recall) / (cumulative_precision + cumulative_recall)) + f1_score = 2 * ((cumulative_precision * cumulative_recall) / (cumulative_precision + cumulative_recall + 0.001)) cumulative_f1_scores.append(f1_score) return cumulative_f1_scores