|
6 | 6 | ) |
7 | 7 | from MetricsReloaded.utility.assignment_localization import AssignmentMapping |
8 | 8 | import numpy as np |
9 | | -from numpy.testing import assert_allclose |
| 9 | +from numpy.testing import assert_allclose, assert_array_almost_equal |
10 | 10 | from sklearn.metrics import cohen_kappa_score as cks |
11 | 11 | from sklearn.metrics import matthews_corrcoef as mcc |
12 | 12 |
|
| 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 | + |
13 | 31 |
|
14 | 32 | ## Data for figure 59 and testing of localisation |
15 | 33 | f59_ref1 = np.zeros([15, 15]) |
|
22 | 40 | f59_pred2 = np.zeros([15, 15]) |
23 | 41 | f59_pred2[4:8, 5:9] = 1 |
24 | 42 |
|
| 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 | + |
25 | 55 | def test_check_localization(): |
26 | 56 | ref_box = [[2,2,4,4]] |
27 | 57 | ref_com = [[3,3]] |
|
0 commit comments