-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
80 lines (72 loc) · 2.34 KB
/
client.py
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
69
70
71
72
73
74
75
76
77
78
79
80
import vantage6.client
IMAGE = 'harbor.carrier-mu.src.surf-hosted.nl/carrier/vertibayes:3.0'
NAME = 'vertibayes from client'
# Example network VertiBayesAsia
INITIAL_NETWORK = [{
"parents": [],
"name": "asia",
"type": "string",
"probabilities": [],
"bins": []
}, {
"parents": ["asia"],
"name": "tub",
"type": "string",
"probabilities": [],
"bins": []
}, {
"parents": [],
"name": "smoke",
"type": "string",
"probabilities": [],
"bins": []
}, {
"parents": ["smoke"],
"name": "lung",
"type": "string",
"probabilities": [],
"bins": []
}, {
"parents": ["smoke"],
"name": "bronc",
"type": "string",
"probabilities": [],
"bins": []
}, {
"parents": ["tub", "lung"],
"name": "either",
"type": "string",
"probabilities": [],
"bins": []
}, {
"parents": ["either"],
"name": "xray",
"type": "string",
"probabilities": [],
"bins": []
}, {
"parents": ["either", "bronc"],
"name": "dysp",
"type": "string",
"probabilities": [],
"bins": []
}]
class VertibayesClient:
def __init__(self, client: vantage6.client.Client):
"""
:param client: Vantage6 client
"""
self.client = client
def vertibayes(self, collaboration, commodity_node, nodes, targetVariable, minPercentage, folds):
return self.client.task.create(collaboration=collaboration,
organizations=[commodity_node],
name=NAME, image=IMAGE, description=NAME,
input={'method': 'vertibayes', 'master': True,
'args': [nodes, INITIAL_NETWORK, targetVariable, minPercentage, folds,
INITIAL_NETWORK]})
def vertibayesNoInitialNetwork(self, collaboration, commodity_node, nodes, targetVariable, minPercentage, folds):
return self.client.task.create(collaboration=collaboration,
organizations=[commodity_node],
name=NAME, image=IMAGE, description=NAME,
input={'method': 'vertibayes', 'master': True,
'args': [nodes, None, targetVariable, minPercentage, folds]})