Skip to content

Commit cdc794e

Browse files
author
Matt Sokoloff
committed
count fp and tps correctly
1 parent 42ed7d5 commit cdc794e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

labelbox/data/metrics/confusion_matrix/calculation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def feature_confusion_matrix(
5959
Returns None if there are no annotations in ground_truth or prediction annotations
6060
"""
6161
if has_no_matching_annotations(ground_truths, predictions):
62-
return [0, int(len(predictions) > 0), 0, int(len(ground_truths) > 0)]
62+
return [0, len(predictions), 0, len(ground_truths)]
6363
elif has_no_annotations(ground_truths, predictions):
6464
return None
6565
elif isinstance(predictions[0].value, Mask):
@@ -96,7 +96,7 @@ def classification_confusion_matrix(
9696
"""
9797

9898
if has_no_matching_annotations(ground_truths, predictions):
99-
return [0, int(len(predictions) > 0), 0, int(len(ground_truths) > 0)]
99+
return [0, len(predictions), 0, len(ground_truths)]
100100
elif has_no_annotations(
101101
ground_truths,
102102
predictions) or len(predictions) > 1 or len(ground_truths) > 1:
@@ -141,7 +141,7 @@ def vector_confusion_matrix(ground_truths: List[ObjectAnnotation],
141141
Returns None if there are no annotations in ground_truth or prediction annotations
142142
"""
143143
if has_no_matching_annotations(ground_truths, predictions):
144-
return [0, int(len(predictions) > 0), 0, int(len(ground_truths) > 0)]
144+
return [0, len(predictions), 0, len(ground_truths)]
145145
elif has_no_annotations(ground_truths, predictions):
146146
return None
147147

@@ -264,7 +264,7 @@ def mask_confusion_matrix(ground_truths: List[ObjectAnnotation],
264264
confusion matrix as a list: [TP,FP,TN,FN]
265265
"""
266266
if has_no_matching_annotations(ground_truths, predictions):
267-
return [0, int(len(predictions) > 0), 0, int(len(ground_truths) > 0)]
267+
return [0, len(predictions), 0, len(ground_truths)]
268268
elif has_no_annotations(ground_truths, predictions):
269269
return None
270270

@@ -306,7 +306,7 @@ def ner_confusion_matrix(ground_truths: List[ObjectAnnotation],
306306
confusion matrix as a list: [TP,FP,TN,FN]
307307
"""
308308
if has_no_matching_annotations(ground_truths, predictions):
309-
return [0, int(len(predictions) > 0), 0, int(len(ground_truths) > 0)]
309+
return [0, len(predictions), 0, len(ground_truths)]
310310
elif has_no_annotations(ground_truths, predictions):
311311
return None
312312
pairs = _get_ner_pairs(ground_truths, predictions)

0 commit comments

Comments
 (0)