def __init__(self, df, depth = 3, significance = 0.05, verbose = False, priorKnowledge = None): tetradData = pycausal.loadDiscreteData(df) indTest = javabridge.JClassWrapper('edu.cmu.tetrad.search.IndTestChiSquare')(tetradData, significance) cpc = javabridge.JClassWrapper('edu.cmu.tetrad.search.Cpc')(indTest) cpc.setDepth(depth) cpc.setVerbose(verbose) if priorKnowledge is not None: cpc.setKnowledge(priorKnowledge) tetradGraph = cpc.search() dags = javabridge.JClassWrapper('edu.cmu.tetrad.search.DagInPatternIterator')(tetradGraph) dagGraph = dags.next() dag = javabridge.JClassWrapper('edu.cmu.tetrad.graph.Dag')(dagGraph) pm = javabridge.JClassWrapper('edu.cmu.tetrad.bayes.BayesPm')(dag) est = javabridge.JClassWrapper('edu.cmu.tetrad.bayes.MlBayesEstimator')() im = est.estimate(pm, tetradData) self.nodes = pycausal.extractTetradGraphNodes(dag) self.edges = pycausal.extractTetradGraphEdges(dag) self.graph = pycausal.generatePyDotGraph(self.nodes,self.edges) self.dag = dag self.bayesPm = pm self.bayesIm = im
def __init__(self, df, depth=3, significance=0.05, verbose=False, priorKnowledge=None): tetradData = pycausal.loadDiscreteData(df) indTest = javabridge.JClassWrapper( 'edu.cmu.tetrad.search.IndTestChiSquare')(tetradData, significance) cpc = javabridge.JClassWrapper('edu.cmu.tetrad.search.Cpc')(indTest) cpc.setDepth(depth) cpc.setVerbose(verbose) if priorKnowledge is not None: cpc.setKnowledge(priorKnowledge) tetradGraph = cpc.search() dags = javabridge.JClassWrapper( 'edu.cmu.tetrad.search.DagInPatternIterator')(tetradGraph) dagGraph = dags.next() dag = javabridge.JClassWrapper('edu.cmu.tetrad.graph.Dag')(dagGraph) pm = javabridge.JClassWrapper('edu.cmu.tetrad.bayes.BayesPm')(dag) est = javabridge.JClassWrapper( 'edu.cmu.tetrad.bayes.MlBayesEstimator')() im = est.estimate(pm, tetradData) self.nodes = pycausal.extractTetradGraphNodes(dag) self.edges = pycausal.extractTetradGraphEdges(dag) self.graph = pycausal.generatePyDotGraph(self.nodes, self.edges) self.dag = dag self.bayesPm = pm self.bayesIm = im
def __init__(self, df, continuous=True, depth=3, aggressivelyPreventCycles=False, significance=0.05, verbose=False, priorKnowledge=None): indTest = None if (continuous): tetradData = pycausal.loadContinuousData(df) indTest = javabridge.JClassWrapper( 'edu.cmu.tetrad.search.IndTestFisherZ')(tetradData, significance) else: tetradData = pycausal.loadDiscreteData(df) indTest = javabridge.JClassWrapper( 'edu.cmu.tetrad.search.IndTestChiSquare')(tetradData, significance) cpcstable = javabridge.JClassWrapper( 'edu.cmu.tetrad.search.CpcStable')(indTest) cpcstable.setDepth(depth) cpcstable.setAggressivelyPreventCycles(aggressivelyPreventCycles) cpcstable.setVerbose(verbose) if priorKnowledge is not None: cpcstable.setKnowledge(priorKnowledge) tetradGraph = cpcstable.search() self.nodes = pycausal.extractTetradGraphNodes(tetradGraph) self.edges = pycausal.extractTetradGraphEdges(tetradGraph) self.graph = pycausal.generatePyDotGraph(self.nodes, self.edges)
def __init__(self, df, continuous=True, depth=3, significance=0.05, verbose=False, priorKnowledge=None): indTest = None if (continuous): tetradData = pycausal.loadContinuousData(df) indTest = javabridge.JClassWrapper( 'edu.cmu.tetrad.search.IndTestFisherZ')(tetradData, significance) else: tetradData = pycausal.loadDiscreteData(df) indTest = javabridge.JClassWrapper( 'edu.cmu.tetrad.search.IndTestChiSquare')(tetradData, significance) ccd = javabridge.JClassWrapper('edu.cmu.tetrad.search.Ccd')(indTest) ccd.setDepth(depth) ccd.setVerbose(verbose) if priorKnowledge is not None: ccd.setKnowledge(priorKnowledge) tetradGraph = ccd.search() self.nodes = pycausal.extractTetradGraphNodes(tetradGraph) self.edges = pycausal.extractTetradGraphEdges(tetradGraph)
def __init__(self, df, structurePrior=1.0, samplePrior=1.0, maxDegree=3, faithfulnessAssumed=True, numofthreads=2, verbose=False, priorKnowledge=None): tetradData = pycausal.loadDiscreteData(df) score = javabridge.JClassWrapper('edu.cmu.tetrad.search.BDeuScore')( tetradData) score.setStructurePrior(structurePrior) score.setSamplePrior(samplePrior) fgs = javabridge.JClassWrapper('edu.cmu.tetrad.search.Fgs')(score) fgs.setMaxDegree(maxDegree) fgs.setNumPatternsToStore(0) fgs.setFaithfulnessAssumed(faithfulnessAssumed) fgs.setParallelism(numofthreads) fgs.setVerbose(verbose) if priorKnowledge is not None: fgs.setKnowledge(priorKnowledge) tetradGraph = fgs.search() self.nodes = pycausal.extractTetradGraphNodes(tetradGraph) self.edges = pycausal.extractTetradGraphEdges(tetradGraph) self.graph = pycausal.generatePyDotGraph(self.nodes, self.edges)
def __init__(self, df, continuous = True, depth = 3, significance = 0.05, verbose = False, priorKnowledge = None): indTest = None if(continuous): tetradData = pycausal.loadContinuousData(df) indTest = javabridge.JClassWrapper('edu.cmu.tetrad.search.IndTestFisherZ')(tetradData, significance) else: tetradData = pycausal.loadDiscreteData(df) indTest = javabridge.JClassWrapper('edu.cmu.tetrad.search.IndTestChiSquare')(tetradData, significance) ccd = javabridge.JClassWrapper('edu.cmu.tetrad.search.Ccd')(indTest) ccd.setDepth(depth) ccd.setVerbose(verbose) if priorKnowledge is not None: ccd.setKnowledge(priorKnowledge) tetradGraph = ccd.search() self.nodes = pycausal.extractTetradGraphNodes(tetradGraph) self.edges = pycausal.extractTetradGraphEdges(tetradGraph)
def __init__(self, df, continuous = True, depth = 3, aggressivelyPreventCycles = False, significance = 0.05, verbose = False, priorKnowledge = None): indTest = None if(continuous): tetradData = pycausal.loadContinuousData(df) indTest = javabridge.JClassWrapper('edu.cmu.tetrad.search.IndTestFisherZ')(tetradData, significance) else: tetradData = pycausal.loadDiscreteData(df) indTest = javabridge.JClassWrapper('edu.cmu.tetrad.search.IndTestChiSquare')(tetradData, significance) cpcstable = javabridge.JClassWrapper('edu.cmu.tetrad.search.CpcStable')(indTest) cpcstable.setDepth(depth) cpcstable.setAggressivelyPreventCycles(aggressivelyPreventCycles) cpcstable.setVerbose(verbose) if priorKnowledge is not None: cpcstable.setKnowledge(priorKnowledge) tetradGraph = cpcstable.search() self.nodes = pycausal.extractTetradGraphNodes(tetradGraph) self.edges = pycausal.extractTetradGraphEdges(tetradGraph) self.graph = pycausal.generatePyDotGraph(self.nodes,self.edges)
def __init__(self, df, structurePrior = 1.0, samplePrior = 1.0, maxDegree = 3, faithfulnessAssumed = True, numofthreads = 2, verbose = False, priorKnowledge = None): tetradData = pycausal.loadDiscreteData(df) score = javabridge.JClassWrapper('edu.cmu.tetrad.search.BDeuScore')(tetradData) score.setStructurePrior(structurePrior) score.setSamplePrior(samplePrior) fges = javabridge.JClassWrapper('edu.cmu.tetrad.search.Fgs')(score) fges.setMaxDegree(maxDegree) fges.setNumPatternsToStore(0) fges.setFaithfulnessAssumed(faithfulnessAssumed) fges.setParallelism(numofthreads) fges.setVerbose(verbose) if priorKnowledge is not None: fges.setKnowledge(priorKnowledge) tetradGraph = fges.search() self.nodes = pycausal.extractTetradGraphNodes(tetradGraph) self.edges = pycausal.extractTetradGraphEdges(tetradGraph) self.graph = pycausal.generatePyDotGraph(self.nodes,self.edges)
def __init__(self, df, structurePrior = 1.0, samplePrior = 1.0, maxInDegree = 3, maxPathLength = -1, significance = 0.05, completeRuleSetUsed = False, faithfulnessAssumed = True, verbose = False, priorKnowledge = None): tetradData = pycausal.loadDiscreteData(df) indTest = javabridge.JClassWrapper('edu.cmu.tetrad.search.IndTestChiSquare')(tetradData, significance) score = javabridge.JClassWrapper('edu.cmu.tetrad.search.BDeuScore')(tetradData) score.setStructurePrior(structurePrior) score.setSamplePrior(samplePrior) gfci = javabridge.JClassWrapper('edu.cmu.tetrad.search.GFci')(indTest, score) gfci.setMaxIndegree(maxInDegree) gfci.setMaxPathLength(maxPathLength) gfci.setCompleteRuleSetUsed(completeRuleSetUsed) gfci.setFaithfulnessAssumed(faithfulnessAssumed) gfci.setVerbose(verbose) if priorKnowledge is not None: gfci.setKnowledge(priorKnowledge) tetradGraph = gfci.search() self.nodes = pycausal.extractTetradGraphNodes(tetradGraph) self.edges = pycausal.extractTetradGraphEdges(tetradGraph)
def __init__(self, df, structurePrior=1.0, samplePrior=1.0, maxInDegree=3, maxPathLength=-1, significance=0.05, completeRuleSetUsed=False, faithfulnessAssumed=True, verbose=False, priorKnowledge=None): tetradData = pycausal.loadDiscreteData(df) indTest = javabridge.JClassWrapper( 'edu.cmu.tetrad.search.IndTestChiSquare')(tetradData, significance) score = javabridge.JClassWrapper('edu.cmu.tetrad.search.BDeuScore')( tetradData) score.setStructurePrior(structurePrior) score.setSamplePrior(samplePrior) gfci = javabridge.JClassWrapper('edu.cmu.tetrad.search.GFci')(indTest, score) gfci.setMaxIndegree(maxInDegree) gfci.setMaxPathLength(maxPathLength) gfci.setCompleteRuleSetUsed(completeRuleSetUsed) gfci.setFaithfulnessAssumed(faithfulnessAssumed) gfci.setVerbose(verbose) if priorKnowledge is not None: gfci.setKnowledge(priorKnowledge) tetradGraph = gfci.search() self.nodes = pycausal.extractTetradGraphNodes(tetradGraph) self.edges = pycausal.extractTetradGraphEdges(tetradGraph)