Skip to content

Commit aa56a00

Browse files
Carole SudreCarole Sudre
authored andcommitted
Update to include figure 6a
1 parent 1abd275 commit aa56a00

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

MetricsReloaded/utility/assignment_localization.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,12 @@ def initial_mapping(self):
437437
possible_binary = np.where(
438438
matrix < self.thresh, np.ones_like(matrix), np.zeros_like(matrix)
439439
)
440+
print(np.sum(possible_binary), "Possible matches from com or dist")
440441
else:
441442
possible_binary = np.where(
442443
matrix > self.thresh, np.ones_like(matrix), np.zeros_like(matrix)
443444
)
445+
print(np.sum(possible_binary), "Possible matches")
444446

445447
list_valid = []
446448
list_matching = []

test/test_utility/test_assignment_localization.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,28 @@
66
)
77
from MetricsReloaded.utility.assignment_localization import AssignmentMapping
88
import numpy as np
9-
from numpy.testing import assert_allclose
9+
from numpy.testing import assert_allclose, assert_array_almost_equal
1010
from sklearn.metrics import cohen_kappa_score as cks
1111
from sklearn.metrics import matthews_corrcoef as mcc
1212

13+
#Data for figure 6a testing of assignment and average precision
14+
ref6c1 = np.asarray([3,2,7,5])
15+
ref6c2 = np.asarray([7,9,8,11])
16+
ref6c3 = np.asarray([1,16,3,18])
17+
ref6c4 = np.asarray([14,14,16,18])
18+
19+
pred6c1 = np.asarray([2,3,6,6])
20+
pred6c2 = np.asarray([2,15,4,17])
21+
pred6c3 = np.asarray([13,13,15,17])
22+
pred6c4 = np.asarray([16,7,19,10])
23+
pred6c5 = np.asarray([12,2,15,4])
24+
25+
pred_proba_6c = [[0.05, 0.95],[0.30,0.70],[0.20,0.80],[0.20,0.80],[0.10,0.90]]
26+
27+
pred_boxes_6c = [pred6c1, pred6c2, pred6c3, pred6c4, pred6c5]
28+
ref_boxes_6c = [ref6c1, ref6c2, ref6c3, ref6c4]
29+
30+
1331

1432
## Data for figure 59 and testing of localisation
1533
f59_ref1 = np.zeros([15, 15])
@@ -22,6 +40,18 @@
2240
f59_pred2 = np.zeros([15, 15])
2341
f59_pred2[4:8, 5:9] = 1
2442

43+
def test_assignment_6c():
44+
asm1 = AssignmentMapping(pred_loc=pred_boxes_6c, ref_loc=ref_boxes_6c, pred_prob=pred_proba_6c, thresh=0.1,localization='box_iou')
45+
df_matching, df_fn, df_fp, list_valid = asm1.initial_mapping()
46+
print(asm1.matrix, df_matching, df_fp, df_fn, list_valid)
47+
numb_fn = df_fn.shape[0]
48+
numb_fp = df_fp.shape[0]
49+
expected_fn = 1
50+
expected_fp = 2
51+
assert expected_fn == numb_fn
52+
assert expected_fp == numb_fp
53+
assert_array_almost_equal(np.asarray(list_valid),np.asarray([0,1,2]))
54+
2555
def test_check_localization():
2656
ref_box = [[2,2,4,4]]
2757
ref_com = [[3,3]]

0 commit comments

Comments
 (0)