causal-learn Python Package
Maintained. Last release 5 months ago, commits in 8 of the last 26 weeks.
pip install causal-learnCausal-learn (documentation, paper) is an open-source platform for causal learning with both classical and state-of-the-art causal discovery algorithms. It aims to recover causal structure from observational data, without requiring interventional experiments, while offering provable correctness guarantees.
The package is actively being developed. Feedback (issues, suggestions, etc.) would be greatly appreciated.
News
Causal discovery is now available anytime, anywhere!
Check out our latest online agentic version of causal-learn: causallearn.com
Package Overview
Our causal-learn implements methods for causal discovery:
- Constraint-based causal discovery methods.
- Score-based causal discovery methods.
- Causal discovery methods based on constrained functional causal models.
- Hidden causal representation learning.
- Permutation-based causal discovery methods.
- Granger causality.
- Multiple utilities for building your own method, such as independence tests, score functions, graph operations, and evaluations.
Install
Causal-learn needs the following packages to be installed beforehand:
- python 3 (>=3.7)
- numpy
- networkx
- pandas
- scipy
- scikit-learn
- statsmodels
- pydot
(For visualization)
- matplotlib
- graphviz
To use causal-learn, we could install it using pip:
pip install causal-learn
Documentation
Please kindly refer to causal-learn Doc for detailed tutorials and usages.
Running examples
For search methods in causal discovery, there are various running examples in the ‘tests’ directory, such as TestPC.py and TestGES.py.
For the implemented modules, such as (conditional) independent test methods, we provide unit tests for the convenience of developing your own methods.