-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_rain.py
54 lines (39 loc) · 1.56 KB
/
run_rain.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
'''
This script shows how to use RAIN algorithm to generate explainable embedding vectors for nodes in a graph.
Note:
Give number of cores as an external argument for generating embedding vectors using parallel processing.
Usage:
python3 run_rain.py <number of cores>
'''
from embedding import RAIN
from metadata import *
import sys
NCORES = int(sys.argv[1])
'''
Following paths directly come from config.ini file.
Instead, you can also directly give these paths directly here.
'''
metadata_dict = dict(
edge_path = EDGE_PATH,
edge_metadata_path = EDGE_METADATA_PATH,
node_metadata_path = NODE_METADATA_PATH,
graph_path = GRAPH_PATH,
embedding_save_path = SAVE_DIRECTORY
)
'''
List of nodeIds (unique identifiers of nodes), whose RAIN embeddings need to be computed.
Option 1: Give the list explicitly as shown here
Option 2: Load the list from an external file
Option 3: Give embedding_nodeId_list = "all", if embeddings of all nodes need to be computed.
'''
embedding_nodeId_list = ['DOID:3777', 'D060050', 'DOID:950', 'DOID:1272', 'DOID:3310', 'DOID:914', 'DOID:9080', 'D004172', 'D019547', 'DOID:519', 'DOID:8442', 'D005207', 'DOID:7489', 'DOID:13450', 'DOID:2527', 'DOID:2973', 'DOID:12900', 'DOID:1023', 'DOID:11406', 'DOID:3343', 'DOID:5500', 'DOID:12128', 'DOID:9120', 'DOID:1793', 'D001766']
def main():
rain = RAIN()
rain.batch_embedding(
metadata_dict = metadata_dict,
embedding_nodeId_list = embedding_nodeId_list,
ncores = NCORES,
nbatch = NBATCH
)
if __name__ == "__main__":
main()