-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrefinement.py
More file actions
68 lines (38 loc) · 1.93 KB
/
Copy pathrefinement.py
File metadata and controls
68 lines (38 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import numpy as np
import config
def extend(y_pred, ids):
for i in range(len(y_pred)):
if y_pred[i] == config.relationships['INSIDE']:
for j in range(len(y_pred)):
if ids[i][0] in ids[j] and y_pred[j] == config.relationships['SAME_AS']:
if ids[i][0] == ids[j][0]:
to_check = [ids[j][1], ids[i][1]]
else:
to_check = [ids[j][0], ids[i][1]]
for k in range(i + 1, len(y_pred)):
if ids[k] == to_check:
y_pred[k] = 2.0
break
if y_pred[i] == 1:
for j in range(len(y_pred)):
if ids[i][0] in ids[j] and i != j and y_pred[j] == 1:
if ids[i][0] == ids[j][0]:
to_check = ids[j][1]
else:
to_check = ids[j][0]
for k in range(len(y_pred)):
if ids[i][1] in ids[k] and to_check in ids[k]:
y_pred[k] = 1.0
break
return
def repair(y_pred, y_probs, ids):
for i in range(len(y_pred)):
if y_pred[i] == config.relationships['INSIDE']:
for j in range(i + 1, len(y_pred)):
if ids[i][0] == ids[j][0] and y_pred[j] == config.relationships['INSIDE'] and ids[i][1] != ids[j][1]:
if abs(y_probs[i] - y_probs[j]) > config.rep_diff and min(y_probs[i], y_probs[j]) < config.rep_thr:
if y_probs[i] < y_probs[j]:
y_pred[i] = 0.0
else:
y_pred[j] = 0.0
return