Skip to content

Commit 16cf35a

Browse files
authored
Merge pull request #87 from bd2kccd/v.1.2.0
Push Version 1.2.0
2 parents 66a5f4c + 43f7fc6 commit 16cf35a

File tree

7 files changed

+27
-22
lines changed

7 files changed

+27
-22
lines changed

meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package:
22
name: pycausal
3-
version: "1.1.1"
3+
version: "1.2.0"
44

55
source:
66
git_rev: v0.1

py-causal-fges-continuous-example.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/local/bin/python
22

3-
43
import os
54
import pandas as pd
65
import pydot
@@ -14,7 +13,7 @@
1413

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

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

34-
pc.stop_vm()
33+
pc.stop_vm()

py-causal-fges-discrete-example.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/local/bin/python
22

3-
43
import os
54
import pandas as pd
65
import pydot
@@ -14,7 +13,7 @@
1413

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

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

35-
pc.stop_vm()
34+
pc.stop_vm()

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
MA 02110-1301 USA
2020
2121
Created on Feb 15, 2016
22-
Updated on Mar 14, 2019
22+
Updated on Aug 9, 2019
2323
2424
@author: Chirayu Wongchokprasitti
2525
'''
@@ -28,7 +28,7 @@
2828

2929
setup(
3030
name = "pycausal",
31-
version = "1.1.1",
31+
version = "1.2.0",
3232
description = "Python wrapper for the Tetrad Library",
3333
author = "Chirayu Kong Wongchokprasitti",
3434
author_email = '[email protected]',

src/pycausal/pycausal.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ def isNodeExisting(self, nodes,node):
6060
print("Node {0} does not exist!".format(node))
6161
return False
6262

63+
def loadTimeSeriesData(self, tetradData, numLags = 1):
64+
tetradData = javabridge.static_call('edu/cmu/tetrad/search/TimeSeriesUtils','createLagData','(Ledu/cmu/tetrad/data/DataSet;I)Ledu/cmu/tetrad/data/DataSet;', tetradData, numLags)
65+
66+
return tetradData
67+
6368
def loadMixedData(self, df, numCategoriesToDiscretize = 4):
6469
tetradData = None
6570

src/pycausal/search.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,23 @@ def listScores(self):
9595
_scores.sort()
9696
print('\n'.join(_scores))
9797

98-
# def getAlgorithmDescription(self, algoId):
99-
# algo = self.algos[algoId]
100-
# algoClass = algo.getClazz()
98+
def getAlgorithmDescription(self, algoId):
99+
algo = self.algos.get(algoId)
100+
algoClass = algo.getClazz()
101101

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

105-
# if tetradAlgors.requireIndependenceTest(algoClass):
106-
# print("\nIt requires the independence test.")
107-
# if tetradAlgors.requireScore(algoClass):
108-
# print("\nIt requires the score.")
109-
# if tetradAlgors.acceptKnowledge(algoClass):
110-
# print("\nIt accepts the prior knowledge.")
111-
# if tetradAlgors.acceptMultipleDataset(algoClass):
112-
# print("\nIt accepts multiple datasets.")
105+
print(algoDescs.get(algoId))
106+
algorithmAnnotations = javabridge.JClassWrapper("edu.cmu.tetrad.annotation.AlgorithmAnnotations")
107+
if algorithmAnnotations.getInstance().requireIndependenceTest(algoClass):
108+
print("\nIt requires the independence test.")
109+
if algorithmAnnotations.getInstance().requireScore(algoClass):
110+
print("\nIt requires the score.")
111+
if algorithmAnnotations.getInstance().acceptKnowledge(algoClass):
112+
print("\nIt accepts the prior knowledge.")
113+
if algorithmAnnotations.getInstance().acceptMultipleDataset(algoClass):
114+
print("\nIt accepts multiple datasets.")
113115

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

0 commit comments

Comments
 (0)