-
Notifications
You must be signed in to change notification settings - Fork 0
/
tetrad_cmd_algs.py
146 lines (131 loc) · 5.1 KB
/
tetrad_cmd_algs.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import os
from datetime import datetime
from causallearn.utils.TXT2GeneralGraph import txt2generalgraph
jar = "causal-cmd-1.4.1-jar-with-dependencies.jar"
stamp = str(datetime.now()).replace(" ", "_")
prefix = "causal_cmd_results/out_" + stamp
# Check whether the specified path exists or not
isExist = os.path.exists("causal_cmd_results")
if not isExist:
# Create a new directory because it does not exist
os.makedirs("causal_cmd_results")
print("A new directory, causal-cmd-results, is created.")
print("Result will be sent to this file: " + prefix + ".txt")
def pc(path, alpha):
os.system("java -Xmx10g -jar " + jar + " "
+ "--default "
+ "--algorithm pc "
+ "--data-type continuous "
+ "--dataset " + path + " "
+ "--test fisher-z-test "
+ "--delimiter tab "
+ "--alpha " + str(alpha) + " "
+ "--verbose "
+ "--prefix " + prefix)
return txt2generalgraph(prefix + ".txt")
def pcmax(path, alpha):
os.system("java -Xmx10g -jar " + jar + " "
+ "--default "
+ "--algorithm pcmax "
+ "--data-type continuous "
+ "--dataset " + path + " "
+ "--test fisher-z-test "
+ "--delimiter tab "
+ "--alpha " + str(alpha) + " "
+ "--verbose "
+ "--prefix " + prefix)
return txt2generalgraph(prefix + ".txt")
def fci(path, alpha):
os.system("java -Xmx10g -jar " + jar + " "
+ "--default "
+ "--algorithm fci "
+ "--data-type continuous "
+ "--dataset " + path + " "
+ "--test fisher-z-test "
+ "--delimiter tab "
+ "--alpha " + str(alpha) + " "
+ "--verbose "
+ "--prefix " + prefix)
return txt2generalgraph(prefix + ".txt")
def fges(path, penaltyDiscount):
os.system("java -Xmx10g -jar " + jar + " "
+ "--default "
+ "--algorithm fges "
+ "--data-type continuous "
+ "--dataset " + path + " "
+ "--score sem-bic-score "
+ "--delimiter tab "
+ "--penaltyDiscount " + str(penaltyDiscount) + " "
+ "--parallel "
+ "--verbose "
+ "--prefix " + prefix)
return txt2generalgraph(prefix + ".txt")
def grasp(path, penaltyDiscount):
os.system("java -Xmx10g -jar " + jar + " "
+ "--default "
+ "--algorithm grasp "
+ "--data-type continuous "
+ "--dataset " + path + " "
+ "--score sem-bic-score "
+ "--test fisher-z-test "
+ "--delimiter tab "
+ "--penaltyDiscount " + str(penaltyDiscount) + " "
+ "--verbose "
+ "--prefix " + prefix)
return txt2generalgraph(prefix + ".txt")
def graspfci(path, penaltyDiscount):
os.system("java -Xmx10g -jar " + jar + " "
+ "--default "
+ "--algorithm graspfci "
+ "--data-type continuous "
+ "--dataset " + path + " "
+ "--score sem-bic-score "
+ "--test fisher-z-test "
+ "--delimiter tab "
+ "--penaltyDiscount " + str(penaltyDiscount) + " "
+ "--verbose "
+ "--prefix " + prefix)
return txt2generalgraph(prefix + ".txt")
def boss_tuck(path, penaltyDiscount):
os.system("java -Xmx10g -jar " + jar + " "
+ "--default "
+ "--experimental "
+ "--algorithm boss-tuck "
+ "--data-type continuous "
+ "--dataset " + path + " "
+ "--score sem-bic-score "
+ "--test fisher-z-test "
+ "--delimiter tab "
+ "--graspUseScore "
+ "--penaltyDiscount " + str(penaltyDiscount) + " "
+ "--verbose "
+ "--prefix " + prefix)
return txt2generalgraph(prefix + ".txt")
def boss(path, penaltyDiscount):
os.system("java -Xmx10g -jar " + jar + " "
+ "--default "
+ "--experimental "
+ "--algorithm boss "
+ "--data-type continuous "
+ "--dataset " + path + " "
+ "--score sem-bic-score "
+ "--test fisher-z-test "
+ "--delimiter tab "
+ "--graspUseScore "
+ "--penaltyDiscount " + str(penaltyDiscount) + " "
+ "--verbose "
+ "--prefix " + prefix)
return txt2generalgraph(prefix + ".txt")
def rges(path, penaltyDiscount):
os.system("java -Xmx10g -jar " + jar + " "
+ "--default "
+ "--experimental "
+ "--algorithm rges "
+ "--data-type continuous "
+ "--dataset " + path + " "
+ "--score sem-bic-score "
+ "--delimiter tab "
+ "--penaltyDiscount " + str(penaltyDiscount) + " "
+ "--verbose "
+ "--prefix " + prefix)
return txt2generalgraph(prefix + ".txt")