From ca90ea9f17199f61605ee5d02ed446e78cc4a275 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Mon, 10 Jun 2019 16:55:07 +0200 Subject: [PATCH] Fixed guardian if to work with numpy arrays 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 4d1dbca..070b9b1 100644 --- a/src/twomartens/masterthesis/evaluate.py +++ b/src/twomartens/masterthesis/evaluate.py @@ -293,7 +293,7 @@ def get_f1_score(cumulative_precisions: List[np.ndarray], for class_id in range(1, nr_classes + 1): cumulative_precision = cumulative_precisions[class_id] cumulative_recall = cumulative_recalls[class_id] - if (cumulative_precision + cumulative_recall) == 0: + 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))