-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_gfci.py
executable file
·65 lines (51 loc) · 1.57 KB
/
demo_gfci.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
#! /usr/bin/env python3
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=["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("airfoil_self_noise.csv", sep=";")
#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())
fges_output = str(fges.search())
fges_output_lines = fges_output.split('\n')
print("\nGFCI\n")
ind_test = ts.IndTestFisherZ(data, .05)
gfci = ts.GFci(ind_test, score)
print(gfci.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()