From 8897a65b3d3a8e6b37cab69a39d7fc7d85fe7cbf Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Thu, 18 Jul 2019 14:58:06 +0200 Subject: [PATCH] Added additional guard clause for cases with no true/false positive entries Signed-off-by: Jim Martens --- src/twomartens/masterthesis/evaluate.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/twomartens/masterthesis/evaluate.py b/src/twomartens/masterthesis/evaluate.py index be47ed2..bdcbcdb 100644 --- a/src/twomartens/masterthesis/evaluate.py +++ b/src/twomartens/masterthesis/evaluate.py @@ -305,7 +305,7 @@ 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: + if number_gt_per_class[class_id] == 0 or cumulative_true_positives[class_id].shape[0] == 0: cumulative_precisions.append([]) cumulative_recalls.append([]) continue @@ -323,8 +323,6 @@ def get_precision_recall(number_gt_per_class: np.ndarray, diff_to_largest_class = cumulative_precision_micro.shape[0] - cumulative_precision.shape[0] if diff_to_largest_class: - print(f"Diff to largest: {diff_to_largest_class}") - print(f"Shape: {tp.shape}") repeated_last_precision = np.tile(cumulative_precision[-1], diff_to_largest_class) repeated_last_recall = np.tile(cumulative_recall[-1], diff_to_largest_class) extended_precision = np.concatenate((cumulative_precision, repeated_last_precision))