-
Notifications
You must be signed in to change notification settings - Fork 0
/
bryan_sample_code.py
55 lines (43 loc) · 1.34 KB
/
bryan_sample_code.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
import numpy as np
import pandas as pd
import jpype
import jpype.imports
from jpype.types import *
# os.system('echo export "JAVA_HOME=\\$(/usr/libexec/java_home)" >> ~/.zshrc')
jpype.startJVM(classpath=["/Users/bryanandrews/Desktop/tetrad-gui-7.2.2-launch.jar"])
import java.util as util
import edu.cmu.tetrad.data as td
import edu.cmu.tetrad.graph as tg
import edu.cmu.tetrad.search as ts
df = pd.read_csv("/Users/bryanandrews/Desktop/airfoil-self-noise.continuous.txt", sep="\t")
# df = pd.read_csv("/Users/bryanandrews/Desktop/ruben_data/bold_data/bold_data_0.txt")
cols = df.columns
values = df.values
n, p = df.shape
databox = td.DoubleDataBox(n, p)
variables = util.ArrayList();
for col, var in enumerate(values.T):
variables.add(td.ContinuousVariable(cols[col]))
for row, val in enumerate(var):
databox.set(row, col, val)
data = td.BoxDataSet(databox, variables)
score = ts.SemBicScore(data)
score.setPenaltyDiscount(2);
score.setStructurePrior(0);
print("\nfGES\n")
fges = ts.Fges(score)
print(fges.search())
print("\nBOSS\n")
boss = ts.Boss(score)
boss.setUseDataOrder(False)
boss.setNumStarts(5)
boss.bestOrder(variables)
print(boss.getGraph(True))
print("\nGRaSP\n")
grasp = ts.Grasp(score)
grasp.setOrdered(False)
grasp.setUseDataOrder(False)
grasp.setNumStarts(5)
grasp.bestOrder(variables)
print(grasp.getGraph(True))
jpype.shutdownJVM()