Skip to content

Commit 6baaba2

Browse files
authored
Renamed confusion matrix components. (#825)
1 parent 300886e commit 6baaba2

24 files changed

+295
-281
lines changed

lite/examples/object-detection.ipynb

+4-4
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@
959959
"id": "98edc4dd",
960960
"metadata": {},
961961
"source": [
962-
"### Hallucinations"
962+
"### Unmatched Predictions"
963963
]
964964
},
965965
{
@@ -1764,7 +1764,7 @@
17641764
}
17651765
],
17661766
"source": [
1767-
"metric.value[\"hallucinations\"]"
1767+
"metric.value[\"unmatched_predictions\"]"
17681768
]
17691769
},
17701770
{
@@ -1773,7 +1773,7 @@
17731773
"id": "415335e4",
17741774
"metadata": {},
17751775
"source": [
1776-
"### Ground Truths Missing Predictions"
1776+
"### Unmatched Ground Truths"
17771777
]
17781778
},
17791779
{
@@ -2995,7 +2995,7 @@
29952995
}
29962996
],
29972997
"source": [
2998-
"metric.value[\"missing_predictions\"]"
2998+
"metric.value[\"unmatched_ground_truths\"]"
29992999
]
30003000
}
30013001
],

lite/examples/tabular_classification.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@
605605
}
606606
],
607607
"source": [
608-
"cm.value[\"missing_predictions\"]"
608+
"cm.value[\"unmatched_ground_truths\"]"
609609
]
610610
}
611611
],

lite/tests/classification/test_confusion_matrix.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_compute_confusion_matrix():
4040

4141
score_thresholds = np.array([0.25, 0.75], dtype=np.float64)
4242

43-
confusion_matrix, missing_predictions = compute_confusion_matrix(
43+
confusion_matrix, unmatched_ground_truths = compute_confusion_matrix(
4444
data=data,
4545
label_metadata=label_metadata,
4646
score_thresholds=score_thresholds,
@@ -74,15 +74,15 @@ def test_compute_confusion_matrix():
7474
)
7575
).all()
7676

77-
assert missing_predictions.shape == (2, 4, 1)
77+
assert unmatched_ground_truths.shape == (2, 4, 1)
7878
assert (
7979
# score >= 0.25
80-
missing_predictions[0, :, 0]
80+
unmatched_ground_truths[0, :, 0]
8181
== np.array([-1.0, -1.0, -1.0, -1.0])
8282
).all()
8383
assert (
8484
# score >= 0.75
85-
missing_predictions[1, :, 0]
85+
unmatched_ground_truths[1, :, 0]
8686
== np.array([-1.0, -1.0, -1.0, 1.0])
8787
).all()
8888

@@ -144,7 +144,7 @@ def test_confusion_matrix_basic(basic_classifications: list[Classification]):
144144
}
145145
},
146146
},
147-
"missing_predictions": {},
147+
"unmatched_ground_truths": {},
148148
},
149149
"parameters": {
150150
"score_threshold": 0.25,
@@ -166,7 +166,7 @@ def test_confusion_matrix_basic(basic_classifications: list[Classification]):
166166
},
167167
}
168168
},
169-
"missing_predictions": {
169+
"unmatched_ground_truths": {
170170
"3": {"count": 1, "examples": [{"datum": "uid2"}]}
171171
},
172172
},
@@ -179,7 +179,7 @@ def test_confusion_matrix_basic(basic_classifications: list[Classification]):
179179
for m in actual_metrics:
180180
_filter_elements_with_zero_count(
181181
cm=m["value"]["confusion_matrix"],
182-
mp=m["value"]["missing_predictions"],
182+
mp=m["value"]["unmatched_ground_truths"],
183183
)
184184
assert m in expected_metrics
185185
for m in expected_metrics:
@@ -212,7 +212,7 @@ def test_confusion_matrix_unit(
212212
"1": {"1": {"count": 1, "examples": []}},
213213
"2": {"1": {"count": 2, "examples": []}},
214214
},
215-
"missing_predictions": {},
215+
"unmatched_ground_truths": {},
216216
},
217217
"parameters": {
218218
"score_threshold": 0.5,
@@ -223,7 +223,7 @@ def test_confusion_matrix_unit(
223223
for m in actual_metrics:
224224
_filter_elements_with_zero_count(
225225
cm=m["value"]["confusion_matrix"],
226-
mp=m["value"]["missing_predictions"],
226+
mp=m["value"]["unmatched_ground_truths"],
227227
)
228228
assert m in expected_metrics
229229
for m in expected_metrics:
@@ -282,7 +282,7 @@ def test_confusion_matrix_with_animal_example(
282282
}
283283
},
284284
},
285-
"missing_predictions": {
285+
"unmatched_ground_truths": {
286286
"dog": {"count": 1, "examples": [{"datum": "uid5"}]}
287287
},
288288
},
@@ -295,7 +295,7 @@ def test_confusion_matrix_with_animal_example(
295295
for m in actual_metrics:
296296
_filter_elements_with_zero_count(
297297
cm=m["value"]["confusion_matrix"],
298-
mp=m["value"]["missing_predictions"],
298+
mp=m["value"]["unmatched_ground_truths"],
299299
)
300300
assert m in expected_metrics
301301
for m in expected_metrics:
@@ -356,7 +356,7 @@ def test_confusion_matrix_with_color_example(
356356
}
357357
},
358358
},
359-
"missing_predictions": {
359+
"unmatched_ground_truths": {
360360
"red": {"count": 1, "examples": [{"datum": "uid2"}]}
361361
},
362362
},
@@ -369,7 +369,7 @@ def test_confusion_matrix_with_color_example(
369369
for m in actual_metrics:
370370
_filter_elements_with_zero_count(
371371
cm=m["value"]["confusion_matrix"],
372-
mp=m["value"]["missing_predictions"],
372+
mp=m["value"]["unmatched_ground_truths"],
373373
)
374374
assert m in expected_metrics
375375
for m in expected_metrics:
@@ -438,7 +438,7 @@ def test_confusion_matrix_multiclass(
438438
}
439439
},
440440
},
441-
"missing_predictions": {},
441+
"unmatched_ground_truths": {},
442442
},
443443
"parameters": {
444444
"score_threshold": 0.05,
@@ -466,7 +466,7 @@ def test_confusion_matrix_multiclass(
466466
}
467467
},
468468
},
469-
"missing_predictions": {
469+
"unmatched_ground_truths": {
470470
"cat": {
471471
"count": 2,
472472
"examples": [{"datum": "uid0"}, {"datum": "uid2"}],
@@ -483,7 +483,7 @@ def test_confusion_matrix_multiclass(
483483
"type": "ConfusionMatrix",
484484
"value": {
485485
"confusion_matrix": {},
486-
"missing_predictions": {
486+
"unmatched_ground_truths": {
487487
"cat": {
488488
"count": 2,
489489
"examples": [{"datum": "uid0"}, {"datum": "uid2"}],
@@ -504,7 +504,7 @@ def test_confusion_matrix_multiclass(
504504
for m in actual_metrics:
505505
_filter_elements_with_zero_count(
506506
cm=m["value"]["confusion_matrix"],
507-
mp=m["value"]["missing_predictions"],
507+
mp=m["value"]["unmatched_ground_truths"],
508508
)
509509
assert m in expected_metrics
510510
for m in expected_metrics:
@@ -560,7 +560,7 @@ def test_confusion_matrix_without_hardmax_animal_example(
560560
},
561561
}
562562
},
563-
"missing_predictions": {},
563+
"unmatched_ground_truths": {},
564564
},
565565
"parameters": {
566566
"score_threshold": 0.05,
@@ -580,7 +580,7 @@ def test_confusion_matrix_without_hardmax_animal_example(
580580
}
581581
}
582582
},
583-
"missing_predictions": {},
583+
"unmatched_ground_truths": {},
584584
},
585585
"parameters": {
586586
"score_threshold": 0.4,
@@ -591,7 +591,7 @@ def test_confusion_matrix_without_hardmax_animal_example(
591591
"type": "ConfusionMatrix",
592592
"value": {
593593
"confusion_matrix": {},
594-
"missing_predictions": {
594+
"unmatched_ground_truths": {
595595
"ant": {
596596
"count": 1,
597597
"examples": [
@@ -611,7 +611,7 @@ def test_confusion_matrix_without_hardmax_animal_example(
611611
for m in actual_metrics:
612612
_filter_elements_with_zero_count(
613613
cm=m["value"]["confusion_matrix"],
614-
mp=m["value"]["missing_predictions"],
614+
mp=m["value"]["unmatched_ground_truths"],
615615
)
616616
assert m in expected_metrics
617617
for m in expected_metrics:

lite/tests/classification/test_dataloader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def test_no_data():
88
loader.finalize()
99

1010

11-
def test_missing_predictions(
11+
def test_unmatched_ground_truths(
1212
classifications_no_predictions: list[Classification],
1313
):
1414
loader = DataLoader()

lite/tests/object_detection/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ def false_negatives_two_images_one_only_with_different_class_high_confidence_of_
704704

705705

706706
@pytest.fixture
707-
def detections_fp_hallucination_edge_case() -> list[Detection]:
707+
def detections_fp_unmatched_prediction_edge_case() -> list[Detection]:
708708
return [
709709
Detection(
710710
uid="uid1",
@@ -1093,7 +1093,7 @@ def detections_for_detailed_counting(
10931093
xmax=rect4[1],
10941094
ymin=rect4[2],
10951095
ymax=rect4[3],
1096-
labels=["hallucination"],
1096+
labels=["no_overlap"],
10971097
scores=[0.1],
10981098
),
10991099
],

lite/tests/object_detection/test_accuracy.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def test_accuracy_metrics_first_class(
9595
groundtruths
9696
datum uid1
9797
box 1 - label v1 - tp
98-
box 3 - label v2 - fn missing prediction
98+
box 3 - label v2 - fn unmatched ground truths
9999
datum uid2
100-
box 2 - label v1 - fn missing prediction
100+
box 2 - label v1 - fn unmatched ground truths
101101
102102
predictions
103103
datum uid1
@@ -176,7 +176,7 @@ def test_accuracy_metrics_second_class(
176176
177177
groundtruths
178178
datum uid1
179-
box 3 - label v2 - fn missing prediction
179+
box 3 - label v2 - fn unmatched ground truths
180180
datum uid2
181181
none
182182
predictions

lite/tests/object_detection/test_average_precision.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_ap_metrics_first_class(
7272
datum uid1
7373
box 1 - label v1 - tp
7474
datum uid2
75-
box 2 - label v1 - fn missing prediction
75+
box 2 - label v1 - fn unmatched ground truths
7676
7777
predictions
7878
datum uid1
@@ -192,7 +192,7 @@ def test_ap_metrics_second_class(
192192
193193
groundtruths
194194
datum uid1
195-
box 3 - label v2 - fn missing prediction
195+
box 3 - label v2 - fn unmatched ground truths
196196
datum uid2
197197
none
198198
predictions

lite/tests/object_detection/test_average_recall.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_ar_metrics_first_class(
8686
datum uid1
8787
box 1 - label v1 - tp
8888
datum uid2
89-
box 2 - label v1 - fn missing prediction
89+
box 2 - label v1 - fn unmatched ground truths
9090
9191
predictions
9292
datum uid1
@@ -198,7 +198,7 @@ def test_ar_metrics_second_class(
198198
199199
groundtruths
200200
datum uid1
201-
box 3 - label v2 - fn missing prediction
201+
box 3 - label v2 - fn unmatched ground truths
202202
datum uid2
203203
none
204204
predictions

0 commit comments

Comments
 (0)