def learn_fci(self, df, tabu_edges): """This function is used to learn model using FCI""" from pycausal.pycausal import pycausal as pc from pycausal import search as s from pycausal import prior as p pc = pc() pc.start_vm() forbid = [list(i) for i in tabu_edges] prior = p.knowledge(forbiddirect=forbid) tetrad = s.tetradrunner() tetrad.getAlgorithmParameters(algoId='fci', testId='fisher-z-test') tetrad.run(algoId='fci', dfs=df, testId='fisher-z-test', depth=-1, maxPathLength=-1, completeRuleSetUsed=False, verbose=False) edges = tetrad.getEdges() dot_str = pc.tetradGraphToDot(tetrad.getTetradGraph()) graph = pydot.graph_from_dot_data(dot_str) # graph[0].write_pdf(fname) pc.stop_vm() return edges
import pandas as pd import pydot from IPython.display import SVG data_dir = os.path.join(os.getcwd(), 'data', 'audiology.txt') df = pd.read_table(data_dir, sep="\t") from pycausal.pycausal import pycausal as pc pc = pc() pc.start_vm(java_max_heap_size='100M') from pycausal import search as s tetrad = s.tetradrunner() tetrad.run(algoId='fges', dfs=df, scoreId='bdeu', dataType='discrete', structurePrior=1.0, samplePrior=1.0, maxDegree=3, faithfulnessAssumed=True, verbose=True) tetrad.getNodes() tetrad.getEdges() dot = tetrad.getDot() dot.write_svg('fges-discrete.svg') pc.stop_vm()
#!/usr/local/bin/python import os import pandas as pd import pydot from IPython.display import SVG data_dir = os.path.join(os.getcwd(), 'data', 'audiology.txt') df = pd.read_table(data_dir, sep="\t") from pycausal.pycausal import pycausal as pc pc = pc() pc.start_vm(java_max_heap_size = '100M') from pycausal import search as s tetrad = s.tetradrunner() tetrad.run(algoId = 'fges', dfs = df, scoreId = 'bdeu', dataType = 'discrete', structurePrior = 1.0, samplePrior = 1.0, maxDegree = 3, faithfulnessAssumed = True, verbose = True) tetrad.getNodes() tetrad.getEdges() dot_str = pc.tetradGraphToDot(tetrad.getTetradGraph()) graphs = pydot.graph_from_dot_data(dot_str) graphs[0].write_svg('fges-discrete.svg') pc.stop_vm()