-
Notifications
You must be signed in to change notification settings - Fork 14
/
test_library.py
38 lines (27 loc) · 1.07 KB
/
test_library.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
###
# Test for prediction library
###
#import the module
import EdgePrediction, json
#create a new instance
ep = EdgePrediction.EdgePrediction()
#load data from edge list
ep.CSV_to_graph(fname = 'data/data.csv', header = True, srcNameCol = 0, srcTypeCol = 1, tgtNameCol = 4, tgtTypeCol = 3, edgeTypeCol = 2)
#filter the source nodes in all graphs so that all the source nodes are common to all input graphs
#keep those nodes and all their edges
#create adjacency matrix
ep.preprocess()
#type of edge to predict
ep.to_predict = 'HAS_SIDE_EFFECT'
#the order can be important as if there are ties, the result found first is returned
#ties may make different predictions
ep.network_order = ['HAS_SIDE_EFFECT', 'DRUG_TARGETS', 'INDICATED_FOR']
#train the model
target_name = "C0027849"
result = ep.predict(target = target_name, calculate_auc = True)
#predicted (unknown) causes of the target ADR
new_predictions = result['new_hits']
#the optimised weights from the model
weights = result['weights']
#the score for all drugs using the trained model
scores = ep.getScores(target_name, weights)