Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
3c4892d
modify the code of GeneralGraph.py and GES.py
Boyle-Coffee Aug 18, 2023
7fd028f
modify the code of GeneralGraph.py and GES.py
Boyle-Coffee Aug 18, 2023
6ff809e
add fast kci
OliverSchacht May 6, 2024
23c9e28
safe null dist for debug
OliverSchacht May 6, 2024
6713550
add fast kci module
OliverSchacht May 6, 2024
7d14060
removed uncessary output for GES
kunwuz Aug 30, 2023
55493bc
updated setup
kunwuz Aug 30, 2023
29e6b58
Add a function to load real-world datasets
kunwuz Aug 31, 2023
c4c5096
update doc
kunwuz Oct 15, 2023
58f45d9
updated doc
kunwuz Sep 22, 2023
1879b6a
update readthedoc config
kunwuz Oct 15, 2023
325f55f
update readthedoc config
kunwuz Oct 15, 2023
5fe7611
update readthedoc config
kunwuz Oct 15, 2023
c4dad3b
update readthedoc config
kunwuz Oct 15, 2023
c680318
update readthedoc config
kunwuz Oct 15, 2023
c6e7189
update readthedoc config
kunwuz Oct 15, 2023
a761ae2
update readthedoc config
kunwuz Oct 15, 2023
cbc3c27
update readthedoc config
kunwuz Oct 15, 2023
9830cd8
update readthedoc config
kunwuz Oct 15, 2023
37417dd
update readthedoc config
kunwuz Oct 15, 2023
b832014
update readthedoc config
kunwuz Oct 15, 2023
7a6ff43
update readthedoc config
kunwuz Oct 15, 2023
6ed1767
update readthedoc config
kunwuz Oct 15, 2023
a55b36c
update typo in a comment
kunwuz Oct 15, 2023
48780a3
uupdate minor descriptions
kunwuz Oct 15, 2023
c311944
Fixed indexing error in dag2pag()
PhilippFaller Oct 27, 2023
ec4861e
update varlingam and 0.1.3.7
kunwuz Nov 2, 2023
ee58783
Endpoint comparison: check only for Endpoint instances
MarkDana Nov 23, 2023
bb77f08
Update KCI.py
fileds Dec 20, 2023
60b8cfd
add reference for pc stable
kunwuz Jan 3, 2024
1ab0207
add reference for pc stable in cdnod
kunwuz Jan 3, 2024
51c4661
Fixed issue#129
zhi-yi-huang Jan 22, 2024
dc2a154
Added a test for updating separated set
zhi-yi-huang Jan 22, 2024
2c5a4d1
Fixed issue#164
zhi-yi-huang Feb 1, 2024
db180c5
realease 0.1.3.8
kunwuz Feb 7, 2024
ae2cd6a
perf: GRaSP allow disable stdout output
X3ZvaWQ Mar 25, 2024
e0d0038
perf: GRaSP function return value type
X3ZvaWQ Mar 25, 2024
deba251
chore: GRaSP function docs append verbose
X3ZvaWQ Mar 25, 2024
8ebc854
updating pruning func for varlingam for faster processing
Apr 4, 2024
c314875
added rules 8,9,10 for FCI
kenneth-lee-ch Feb 15, 2024
08add05
clean up whitespace
kenneth-lee-ch Feb 15, 2024
4220038
updated doc
kunwuz Apr 11, 2024
c3a6ac3
updated readme
kunwuz Apr 12, 2024
201f1b5
Update FCI.py for fixing isNoncollider
svenpieper Apr 8, 2024
9ce0388
Update FCI.py - using node_map to only get node_map func once
svenpieper Apr 8, 2024
ae9b93a
update UInd test
OliverSchacht May 28, 2024
430f3e5
add rcit
OliverSchacht Sep 18, 2024
1a700b9
redo naming of rcit class
OliverSchacht Sep 19, 2024
043d915
debugging
OliverSchacht Sep 19, 2024
f172a26
add docstrings
OliverSchacht Oct 16, 2024
3917886
linting
OliverSchacht Oct 16, 2024
c92bd39
Add node_names to GRaSP.py
EvieQ01 Jun 24, 2024
e318aa0
Add node_names
EvieQ01 Jul 2, 2024
ed08956
Allow orientation within the same tier
EvieQ01 Jul 2, 2024
b74e1ac
Revert "Add node_names"
EvieQ01 Jul 3, 2024
425bc05
fixed
EvieQ01 Jul 3, 2024
16210d4
Add R5, 6, 7 for the Augmented FCI
EvieQ01 Aug 30, 2024
b9f8e8f
fixed finding possible parents
kenneth-lee-ch Aug 22, 2024
3cbfbfe
Update CODE_OF_CONDUCT.md
kunwuz Jul 3, 2024
7ba0513
introduced a way to use the local score object without caching
bja43 Jul 14, 2024
48d8a92
removing maxP because it dodnt do anything
bja43 Jul 15, 2024
9915f0b
fixed grasp unittest
bja43 Jul 16, 2024
1ef83e5
adding gsts and boss
bja43 Jul 17, 2024
4f43349
algorithms are working by efficiency is lackluster
bja43 Jul 17, 2024
1a53055
final updates to BOSS and GRaSP
bja43 Jul 18, 2024
ebc80c9
final updates
bja43 Jul 18, 2024
b9b4294
fix: fix LocalScoreFunction.py
zhi-yi-huang Aug 25, 2024
c673495
Minor changes
EvieQ01 Sep 5, 2024
28e6ba5
Bug fix in finding undirected circle paths, and allow multiple ucp
EvieQ01 Sep 25, 2024
6088178
modify change_flag
EvieQ01 Sep 28, 2024
1dd6b2f
DAG to a maximal PAG by adding rule5-10 and adding selection variables
EvieQ01 Sep 28, 2024
58c50ca
fix: orient the edge between alpha and beta as an undirected edge.
zhi-yi-huang Oct 6, 2024
d8d6a0c
fix: fci unittest
zhi-yi-huang Oct 6, 2024
50b6030
edit docstring
OliverSchacht Oct 17, 2024
d3ae1bc
remove experimental stuff
OliverSchacht Oct 17, 2024
f58a91a
remove propensity trimming
OliverSchacht Oct 21, 2024
299d7e5
add unit tests
OliverSchacht Oct 21, 2024
b13fdda
Create python-package.yml
OliverSchacht Oct 21, 2024
a1c65e4
Update python-package.yml
OliverSchacht Oct 21, 2024
21cb82d
Update python-package.yml
OliverSchacht Oct 21, 2024
c517f5c
spelling
OliverSchacht Oct 21, 2024
59b1ea9
fix: array dtype
OliverSchacht Oct 21, 2024
5b89aa8
Update python-package.yml
OliverSchacht Oct 21, 2024
a742e9f
remove my workflow
OliverSchacht Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
identity and expression, level of experience, education, socioeconomic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# causal-learn: Causal Discovery in Python

Causal-learn is a python package for causal discovery that implements both classical and state-of-the-art causal discovery algorithms, which is a Python translation and extension of [Tetrad](https://github.com/cmu-phil/tetrad).
Causal-learn ([documentation](https://causal-learn.readthedocs.io/en/latest/), [paper](https://jmlr.org/papers/volume25/23-0970/23-0970.pdf)) is a python package for causal discovery that implements both classical and state-of-the-art causal discovery algorithms, which is a Python translation and extension of [Tetrad](https://github.com/cmu-phil/tetrad).

The package is actively being developed. Feedbacks (issues, suggestions, etc.) are highly encouraged.

Expand Down Expand Up @@ -76,10 +76,13 @@ Although causal-learn provides python implementations for some causal discovery
Please cite as:

```
@article{causallearn,
title={Causal-learn: Causal Discovery in Python},
author={Yujia Zheng and Biwei Huang and Wei Chen and Joseph Ramsey and Mingming Gong and Ruichu Cai and Shohei Shimizu and Peter Spirtes and Kun Zhang},
journal={arXiv preprint arXiv:2307.16405},
year={2023}
@article{zheng2024causal,
title={Causal-learn: Causal discovery in python},
author={Zheng, Yujia and Huang, Biwei and Chen, Wei and Ramsey, Joseph and Gong, Mingming and Cai, Ruichu and Shimizu, Shohei and Spirtes, Peter and Zhang, Kun},
journal={Journal of Machine Learning Research},
volume={25},
number={60},
pages={1--8},
year={2024}
}
```
2 changes: 1 addition & 1 deletion causallearn/graph/Endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def __str__(self):
return self.name

def __eq__(self, other):
return self.value == other.value
return isinstance(other, Endpoint) and self.value == other.value
6 changes: 4 additions & 2 deletions causallearn/graph/GeneralGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,13 +508,15 @@ def is_ancestor_of(self, node1: Node, node2: Node) -> bool:
def is_child_of(self, node1: Node, node2: Node) -> bool:
i = self.node_map[node1]
j = self.node_map[node2]
return self.graph[i, j] == Endpoint.TAIL.value or self.graph[i, j] == Endpoint.ARROW_AND_ARROW.value
return (self.graph[j, i] == Endpoint.TAIL.value and self.graph[i, j] == Endpoint.ARROW.value) \
or self.graph[j, i] == Endpoint.TAIL_AND_ARROW.value

# Returns true iff node1 is a parent of node2.
def is_parent_of(self, node1: Node, node2: Node) -> bool:
i = self.node_map[node1]
j = self.node_map[node2]
return self.graph[j, i] == Endpoint.ARROW.value and self.graph[i, j] == Endpoint.TAIL.value
return (self.graph[j, i] == Endpoint.ARROW.value and self.graph[i, j] == Endpoint.TAIL.value) \
or self.graph[i, j] == Endpoint.TAIL_AND_ARROW.value

# Returns true iff node1 is a proper ancestor of node2.
def is_proper_ancestor_of(self, node1: Node, node2: Node) -> bool:
Expand Down
16 changes: 8 additions & 8 deletions causallearn/score/LocalScoreFunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def local_score_BIC(Data: ndarray, i: int, PAi: List[int], parameters=None) -> f
if len(PAi) == 0:
return n * np.log(cov[i, i])

yX = np.mat(cov[np.ix_([i], PAi)])
XX = np.mat(cov[np.ix_(PAi, PAi)])
H = np.log(cov[i, i] - yX * np.linalg.inv(XX) * yX.T)
yX = cov[np.ix_([i], PAi)]
XX = cov[np.ix_(PAi, PAi)]
H = np.log(cov[i, i] - yX @ np.linalg.inv(XX) @ yX.T)

return n * H + np.log(n) * len(PAi) * lambda_value

Expand Down Expand Up @@ -68,9 +68,9 @@ def local_score_BIC_from_cov(
if len(PAi) == 0:
return n * np.log(cov[i, i])

yX = np.mat(cov[np.ix_([i], PAi)])
XX = np.mat(cov[np.ix_(PAi, PAi)])
H = np.log(cov[i, i] - yX * np.linalg.inv(XX) * yX.T)
yX = cov[np.ix_([i], PAi)]
XX = cov[np.ix_(PAi, PAi)]
H = np.log(cov[i, i] - yX @ np.linalg.inv(XX) @ yX.T)

return n * H + np.log(n) * len(PAi) * lambda_value

Expand Down Expand Up @@ -198,7 +198,7 @@ def local_score_cv_general(
PAi = list(PAi)

T = Data.shape[0]
X = Data[:, Xi]
X = Data[:, [Xi]]
var_lambda = parameters["lambda"] # regularization parameter
k = parameters["kfold"] # k-fold cross validation
n0 = math.floor(T / k)
Expand Down Expand Up @@ -715,7 +715,7 @@ def local_score_marginal_general(
"""

T = Data.shape[0]
X = Data[:, Xi]
X = Data[:, [Xi]]
dX = X.shape[1]

# set the kernel for X
Expand Down
6 changes: 6 additions & 0 deletions causallearn/score/LocalScoreFunctionClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ def score(self, i: int, PAi: List[int]) -> float:
self.score_cache[i][hash_key] = self.local_score_fun(self.data, i, PAi, self.parameters)

return self.score_cache[i][hash_key]

def score_nocache(self, i: int, PAi: List[int]) -> float:
if self.local_score_fun == local_score_BIC_from_cov:
return self.local_score_fun((self.cov, self.n), i, PAi, self.parameters)
else:
return self.local_score_fun(self.data, i, PAi, self.parameters)
Loading