From bdd0862d681e30e7e9ea3e799ccb60c74f218900 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 9 Jul 2019 13:45:01 +0200 Subject: [PATCH] Added guardian function to catch case with zero ground truth Signed-off-by: Jim Martens --- src/twomartens/masterthesis/evaluate.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/twomartens/masterthesis/evaluate.py b/src/twomartens/masterthesis/evaluate.py index 7b277a1..2ae43e1 100644 --- a/src/twomartens/masterthesis/evaluate.py +++ b/src/twomartens/masterthesis/evaluate.py @@ -262,6 +262,11 @@ def get_precision_recall(number_gt_per_class: np.ndarray, # Iterate over all classes. for class_id in range(1, nr_classes + 1): + + if number_gt_per_class[class_id] == 0: + cumulative_precisions.append([]) + cumulative_recalls.append([]) + continue tp = cumulative_true_positives[class_id] fp = cumulative_false_positives[class_id]