-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathrun_CGNN_graph.py
31 lines (23 loc) · 987 Bytes
/
run_CGNN_graph.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
import cgnn
import sys
import pandas as pd
# Params
cgnn.SETTINGS.GPU = True
cgnn.SETTINGS.NB_GPU = 2
cgnn.SETTINGS.NB_JOBS = 8
cgnn.SETTINGS.NB_RUNS = 32
datafile = "Example_graph_numdata.csv"
skeletonfile = "Example_graph_skeleton.csv"
print("Processing " + datafile + "...")
undirected_links = pd.read_csv(skeletonfile)
umg = cgnn.UndirectedGraph(undirected_links)
data = pd.read_csv(datafile)
GNN = cgnn.GNN(backend="TensorFlow")
p_directed_graph = GNN.orient_graph(data, umg, printout=datafile + '_printout.csv')
gnn_res = pd.DataFrame(p_directed_graph.get_list_edges(descending=True), columns=['Cause', 'Effect', 'Score'])
gnn_res.to_csv(datafile + "_pairwise_predictions.csv")
CGNN = cgnn.CGNN(backend="TensorFlow")
directed_graph = CGNN.orient_directed_graph(data, p_directed_graph)
cgnn_res = pd.DataFrame(directed_graph.get_list_edges(descending=True), columns=['Cause', 'Effect', 'Score'])
cgnn_res.to_csv(datafile + "_predictions.csv")
print('Processed ' + datafile)