Skip to main content

causal-learn Python Package

Project description

causal-learn: Learning Causality from Data

Causal-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.

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.

Benchmarks

For the convenience of our community, CMU-CLeaR group maintains a list of benchmark datasets including real-world scenarios and various learning tasks. Please refer to the following links:

Please feel free to let us know if you have any recommendations regarding causal datasets with high-quality. We are grateful for any effort that benefits the development of the causality community.

Contribution

Please feel free to open an issue if you find anything unexpected. And please create pull requests, perhaps after passing unittests in 'tests/', if you would like to contribute to causal-learn. We are always targeting to make our community better!

Running Tetrad in Python

Although causal-learn provides Python implementations for many causal discovery algorithms, there are more in the classical Java-based Tetrad program. For users who would like to incorporate arbitrary Java code in Tetrad as part of a Python workflow, we strongly recommend considering py-tetrad. Here is a list of reusable examples of how to painlessly benefit from the most comprehensive Tetrad Java codebase.

Citation

Please cite as:

@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}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

causal_learn-0.1.4.6.tar.gz (201.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

causal_learn-0.1.4.6-py3-none-any.whl (245.5 kB view details)

Uploaded Python 3

File details

Details for the file causal_learn-0.1.4.6.tar.gz.

File metadata

  • Download URL: causal_learn-0.1.4.6.tar.gz
  • Upload date:
  • Size: 201.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.7

File hashes

Hashes for causal_learn-0.1.4.6.tar.gz
Algorithm Hash digest
SHA256 4903d77bb479a2882caae974e8aaf31de0397be1201009e0f4f8e30c6b490dcc
MD5 3dcd7a9bbbcc30164c17aea9cd3af488
BLAKE2b-256 7a86bd42dae88b206f4b680d75011f24acb81637abdae625a31d3820dc80debf

See more details on using hashes here.

File details

Details for the file causal_learn-0.1.4.6-py3-none-any.whl.

File metadata

  • Download URL: causal_learn-0.1.4.6-py3-none-any.whl
  • Upload date:
  • Size: 245.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.7

File hashes

Hashes for causal_learn-0.1.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e1400b59e7537dfcf830356b310a916f3e85b1bf29861c8bb59d3d1aaafb9697
MD5 c6353568b2bc0fa51c8c338a1a74a543
BLAKE2b-256 7449db637527b5e012855f4a8b8653811621e26df2a735a32ca522c1fa80bec5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page