Skip to content

Commit

Permalink
Merge pull request #87 from bd2kccd/v.1.2.0
Browse files Browse the repository at this point in the history
Push Version 1.2.0
  • Loading branch information
chirayukong authored Aug 8, 2019
2 parents 66a5f4c + 43f7fc6 commit 16cf35a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: pycausal
version: "1.1.1"
version: "1.2.0"

source:
git_rev: v0.1
Expand Down
5 changes: 2 additions & 3 deletions py-causal-fges-continuous-example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/local/bin/python


import os
import pandas as pd
import pydot
Expand All @@ -14,7 +13,7 @@

from pycausal import search as s
tetrad = s.tetradrunner()
tetrad.run(algoId = 'fges', dfs = df, scoreId = 'sem-bic-score', dataType = 'continuous',
tetrad.run(algoId = 'fges', dfs = df, scoreId = 'sem-bic', dataType = 'continuous',
maxDegree = -1, faithfulnessAssumed = True, verbose = True)

print(tetrad.getNodes())
Expand All @@ -31,4 +30,4 @@
graphs = pydot.graph_from_dot_data(dot_str)
graphs[0].write_svg('fges-continuous.svg')

pc.stop_vm()
pc.stop_vm()
5 changes: 2 additions & 3 deletions py-causal-fges-discrete-example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/local/bin/python


import os
import pandas as pd
import pydot
Expand All @@ -14,7 +13,7 @@

from pycausal import search as s
tetrad = s.tetradrunner()
tetrad.run(algoId = 'fges', dfs = df, scoreId = 'bdeu-score', dataType = 'discrete',
tetrad.run(algoId = 'fges', dfs = df, scoreId = 'cg-bic-score', dataType = 'discrete',
maxDegree = 3, faithfulnessAssumed = True,
symmetricFirstStep = True, verbose = True)

Expand All @@ -32,4 +31,4 @@
graphs = pydot.graph_from_dot_data(dot_str)
graphs[0].write_svg('fges-discrete.svg')

pc.stop_vm()
pc.stop_vm()
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
MA 02110-1301 USA
Created on Feb 15, 2016
Updated on Mar 14, 2019
Updated on Aug 9, 2019
@author: Chirayu Wongchokprasitti
'''
Expand All @@ -28,7 +28,7 @@

setup(
name = "pycausal",
version = "1.1.1",
version = "1.2.0",
description = "Python wrapper for the Tetrad Library",
author = "Chirayu Kong Wongchokprasitti",
author_email = '[email protected]',
Expand Down
Binary file not shown.
5 changes: 5 additions & 0 deletions src/pycausal/pycausal.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def isNodeExisting(self, nodes,node):
print("Node {0} does not exist!".format(node))
return False

def loadTimeSeriesData(self, tetradData, numLags = 1):
tetradData = javabridge.static_call('edu/cmu/tetrad/search/TimeSeriesUtils','createLagData','(Ledu/cmu/tetrad/data/DataSet;I)Ledu/cmu/tetrad/data/DataSet;', tetradData, numLags)

return tetradData

def loadMixedData(self, df, numCategoriesToDiscretize = 4):
tetradData = None

Expand Down
28 changes: 15 additions & 13 deletions src/pycausal/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,23 @@ def listScores(self):
_scores.sort()
print('\n'.join(_scores))

# def getAlgorithmDescription(self, algoId):
# algo = self.algos[algoId]
# algoClass = algo.getClazz()
def getAlgorithmDescription(self, algoId):
algo = self.algos.get(algoId)
algoClass = algo.getClazz()

# tetradAlgorithms = javabridge.JClassWrapper("edu.pitt.dbmi.causal.cmd.tetrad.TetradAlgorithms")
# tetradAlgors = tetradAlgorithms.getInstance()
algorithmDescriptions = javabridge.JClassWrapper("edu.cmu.tetrad.util.AlgorithmDescriptions")
algoDescs = algorithmDescriptions.getInstance()

# if tetradAlgors.requireIndependenceTest(algoClass):
# print("\nIt requires the independence test.")
# if tetradAlgors.requireScore(algoClass):
# print("\nIt requires the score.")
# if tetradAlgors.acceptKnowledge(algoClass):
# print("\nIt accepts the prior knowledge.")
# if tetradAlgors.acceptMultipleDataset(algoClass):
# print("\nIt accepts multiple datasets.")
print(algoDescs.get(algoId))
algorithmAnnotations = javabridge.JClassWrapper("edu.cmu.tetrad.annotation.AlgorithmAnnotations")
if algorithmAnnotations.getInstance().requireIndependenceTest(algoClass):
print("\nIt requires the independence test.")
if algorithmAnnotations.getInstance().requireScore(algoClass):
print("\nIt requires the score.")
if algorithmAnnotations.getInstance().acceptKnowledge(algoClass):
print("\nIt accepts the prior knowledge.")
if algorithmAnnotations.getInstance().acceptMultipleDataset(algoClass):
print("\nIt accepts multiple datasets.")

def getAlgorithmParameters(self, algoId, testId = None, scoreId = None):
algo = self.algos.get(algoId)
Expand Down

0 comments on commit 16cf35a

Please sign in to comment.