Causal-learn: Causal Discovery in Python

Yujia ZhengBiwei HuangWei ChenJoseph D. RamseyMingming GongRuichu CaiShohei ShimizuPeter SpirtesKun Zhang

article2024JMLR181 citations

Presents causal-learn, a native Python open-source library that unifies major constraint-based, score-based, and functional causal discovery algorithms alongside modular independence tests and evaluation metrics without relying on R or Java dependencies.

Listen

Understanding cause-and-effect relationships is vital across scientific research and industry, from identifying disease-causing genes in healthcare to optimizing complex engineering systems. While randomized controlled experiments are the gold standard for discovering these relationships, they are frequently too costly, slow, or logistically impractical to execute. Consequently, organizations increasingly seek to discover causal connections directly from observational data that already exist in large volumes. However, existing software tools for causal discovery have historically relied on legacy languages such as Java and R, creating substantial barriers for modern data science pipelines centered around Python.

The article introduces and evaluates causal-learn, an open-source software library built entirely in Python to make causal discovery accessible, extensible, and practical across scientific and enterprise workflows. The platform provides a unified environment containing the major algorithmic approaches required to extract causal graphs from observational datasets.

To address existing software gaps, the project implements four primary causal discovery paradigms within a modular framework: constraint-based methods, score-based methods, functional causal model methods, and techniques designed to identify hidden or unobserved variables. Crucially, the platform operates purely natively in Python, eliminating foreign-language wrappers and external dependencies that previously complicated software deployment and customization. The authors provide standardized programming interfaces, prepackaged benchmark datasets with known causal graphs, and standalone modules for statistical independence testing, scoring, and graph transformation.

The findings and technical contributions center on several core capabilities. First, causal-learn integrates all four dominant causal discovery categories into a single platform, uniting classic algorithms with recent state-of-the-art methods that model non-linear relations and hidden variables. Second, its native Python architecture eliminates deployment overhead and dependency conflicts, allowing organizations to integrate causal modeling directly into production machine learning workflows and downstream causal inference pipelines. Third, the modular design isolates statistical tests and graph operations, enabling analysts to customize algorithms without rewriting core infrastructure. Finally, the inclusion of curated benchmark datasets helps mitigate the persistent industry challenge of evaluating causal discovery accuracy against verifiable ground truths.

These capabilities significantly lower the technical and operational barriers to deploying causal discovery. Organizations can reduce experimentation costs and accelerate research by screening observational data before committing to expensive physical trials. Furthermore, the platform integrates smoothly with downstream inference tools, enabling end-to-end causal decision pipelines that operate within standard enterprise Python environments.

Organizations should adopt causal-learn for observational analysis workflows while planning to link discovered graphs directly to downstream causal inference frameworks. Because causal discovery methods inherently rely on statistical assumptions such as distribution types or the presence of hidden variables, analysts should carefully evaluate whether data meet specific algorithm requirements. Continued development and community curation of real-world benchmark datasets remain essential to validate performance across diverse operating domains.

No sufficiently relevant recommendations were found.

Cover for Causal-learn: Causal Discovery in Python

Abstract

Causal discovery aims at revealing causal relations from observational data, which is a fundamental task in science and engineering. We describe causal-learn, an open-source Python library for causal discovery. This library focuses on bringing a comprehensive collection of causal discovery methods to both practitioners and researchers. It provides easy-to-use APIs for non-specialists, modular building blocks for developers, detailed documentation for learners, and comprehensive methods for all. Different from previous packages in R or Java, causal-learn is fully developed in Python, which could be more in tune with the recent preference shift in programming languages within related communities. The library is available at https://github.com/py-why/causal-learn.

Table of Contents

  • 1. Introduction
  • 2. Design
  • 2.1 Methods
  • 2.2 Utilities
  • 2.3 Demos, APIs, and benchmark datasets
  • 3. Conclusion
  • Acknowledgments
  • References

Knowls

  1. Knowl 1 — A fully Python, modular platform for causal discovery

    model/method

    Causal-learn is an open-source Python library for causal discovery from data, implemented in Python without requiring Java or R. It combines user-facing APIs and documentation with separately usable components for (conditional) independence tests, score functions, graph operations, and evaluation metrics. The modular design is intended to let practitioners apply existing methods and let developers adapt implementations or build new methods within the Python ecosystem. The library is available at https://github.com/py-why/causal-learn.

  2. Knowl 2 — Causal-discovery methods and statistical components included in version 0.1.3.8

    data/table

    Causal-learn version 0.1.3.8 covers several families of causal-discovery methods, and also exposes independence tests and score functions as package components. The inventory below distinguishes the discovery families from the statistical tests and scoring options available for use by those methods or in custom workflows.

    Category Methods or components
    Constraint-based causal discovery PC, MV-PC, FCI, CD-NOD
    Score-based causal discovery GES, A*, Dynamic Programming, GRaSP
    Function-based causal discovery ANM, PNL, LiNGAM, DirectLiNGAM, VAR-LiNGAM, RCD, CAM-UV
    Causal representation learning GIN
    (Conditional) independence tests Fisher-z, missing-value Fisher-z, Chi-Square, KCI conditional-independence and independence tests, G-Square
    Score functions BIC, BDeu, Generalized Score
  3. Knowl 3 — Graph conversions and structural evaluation utilities

    model/method

    Causal-learn provides graph operations for working with graphical objects used in causal discovery, including directed acyclic graphs (DAGs), completed partially directed acyclic graphs (CPDAGs), partially directed acyclic graphs (PDAGs), and partially ancestral graphs (PAGs). It also supplies precision and recall metrics for arrow directions or adjacency matrices, and Structural Hamming Distance (SHD), supporting comparison of estimated and reference structures.

  4. Knowl 4 — Examples, documentation, and benchmark-dataset access

    model/method

    Causal-learn includes usage examples for its search methods, (conditional) independence tests, score functions, and utilities, as well as documentation covering its APIs and data structures. The library also provides a collection of benchmark datasets and functions to import them. The paper motivates these datasets as support for evaluating causal-discovery methods in a setting where real-data ground-truth relations are often unavailable, and as a possible stimulus for collecting more datasets with at least partially known causal relations.

Coverage note — No substantial contributed material was omitted; the paper presents a software library and its capabilities, rather than new causal theory or a comparative empirical evaluation.

References

  1. 1.Silvia Acid and Luis M de Campos. Searching for bayesian network structures in the space of restricted acyclic partially directed graphs. Journal of Artificial Intelligence Research, 18:445–490, 2003.
  2. 2.Bryan Andrew and Joseph Ramsey. py-tetrad, 2023. URL https://github.com/cmu-phil/py-tetrad.
  3. 3.Wray Buntine. Theory refinement on bayesian networks. In Uncertainty proceedings 1991, pages 52–60. Elsevier, 1991.
  4. 4.David Maxwell Chickering. Optimal structure identification with greedy search. Journal of machine learning research, 3(Nov):507–554, 2002.
  5. 5.Ronald Aylmer Fisher et al. 014: On the” probable error” of a coefficient of correlation deduced from a small sample. 1921.
  6. 6.Clark Glymour and Richard Scheines. Causal modeling with the tetrad program. Synthese, 68:37–63, 1986.
  7. 7.Clark Glymour, Kun Zhang, and Peter Spirtes. Review of causal discovery methods based on graphical models. Frontiers in genetics, 10:524, 2019.
  8. 8.Patrik O Hoyer, Dominik Janzing, Joris M Mooij, Jonas Peters, Bernhard Sch¨olkopf, et al. Nonlinear causal discovery with additive noise models. In NIPS, volume 21, pages 689–696. Citeseer, 2008.
  9. 9.Biwei Huang, Kun Zhang, Yizhu Lin, Bernhard Sch¨olkopf, and Clark Glymour. Generalized score functions for causal discovery. In Proceedings of the 24th ACM SIGKDD international conference on knowledge discovery & data mining, pages 1551–1560, 2018.
  10. 10.Biwei Huang, Kun Zhang, Jiji Zhang, Joseph D Ramsey, Ruben Sanchez-Romero, Clark Glymour, and Bernhard Sch¨olkopf. Causal discovery from heterogeneous/nonstationary data. J. Mach. Learn. Res., 21(89):1–53, 2020.
  11. 11.Aapo Hyv¨arinen, Kun Zhang, Shohei Shimizu, and Patrik O Hoyer. Estimation of a structural vector autoregression model using non-gaussianity. Journal of Machine Learning Research, 11(5), 2010.
  12. 12.Takashi Ikeuchi, Mayumi Ide, Yan Zeng, Takashi Nicholas Maeda, and Shohei Shimizu. Python package for causal discovery based on lingam. vol, 24:1–8, 2023.
  13. 13.Diviyan Kalainathan, Olivier Goudet, and Ritik Dutta. Causal discovery toolbox: Uncovering causal relationships in python. The Journal of Machine Learning Research, 21(1):1406–1410, 2020.
  14. 14.Markus Kalisch, Martin M¨achler, Diego Colombo, Marloes H. Maathuis, and Peter B¨uhlmann. Causal inference using graphical models with the R package pcalg. Journal of Statistical Software, 47(11):1–26, 2012. doi: 10.18637/jss.v047.i11.
  15. 15.Wai-Yin Lam, Bryan Andrews, and Joseph Ramsey. Greedy relaxations of the sparsest permutation algorithm. In Uncertainty in Artificial Intelligence, pages 1052–1062. PMLR, 2022.
  16. 16.Jaron JR Lee, Rohit Bhattacharya, Razieh Nabi, and Ilya Shpitser. Ananke: A python package for causal inference using graphical models. arXiv preprint arXiv:2301.11477, 2023.
  17. 17.Takashi Nicholas Maeda and Shohei Shimizu. Rcd: Repetitive causal discovery of linear non-gaussian acyclic models with latent confounders. In International Conference on Artificial Intelligence and Statistics, pages 735–745. PMLR, 2020.
  18. 18.Takashi Nicholas Maeda and Shohei Shimizu. Causal additive models with unobserved variables. In Uncertainty in Artificial Intelligence, pages 97–106. PMLR, 2021.
  19. 19.Joseph D Ramsey, Kun Zhang, Madelyn Glymour, Ruben Sanchez Romero, Biwei Huang, Imme Ebert-Uphoff, Savini Samarasinghe, Elizabeth A Barnes, and Clark Glymour. Tetrad—a toolbox for causal discovery. In 8th international workshop on climate informatics, page 29, 2018.
  20. 20.Richard Scheines, Peter Spirtes, Clark Glymour, Christopher Meek, and Thomas Richardson. The tetrad project: Constraint based aids to causal model specification. Multivariate Behavioral Research, 33(1):65–117, 1998.
  21. 21.Bernhard Sch¨olkopf, Francesco Locatello, Stefan Bauer, Nan Rosemary Ke, Nal Kalchbrenner, Anirudh Goyal, and Yoshua Bengio. Toward causal representation learning. Proceedings of the IEEE, 109(5):612–634, 2021.
  22. 22.Gideon Schwarz. Estimating the dimension of a model. The annals of statistics, pages 461–464, 1978.
  23. 23.Marco Scutari. Learning bayesian networks with the bnlearn R package. Journal of Statistical Software, 35(3):1–22, 2010. doi: 10.18637/jss.v035.i03.
  24. 24.Amit Sharma and Emre Kiciman. Dowhy: An end-to-end library for causal inference. arXiv preprint arXiv:2011.04216, 2020.
  25. 25.Shohei Shimizu, Patrik O Hoyer, Aapo Hyv¨arinen, Antti Kerminen, and Michael Jordan. A linear non-Gaussian acyclic model for causal discovery. Journal of Machine Learning Research, 7(10), 2006.
  26. 26.Shohei Shimizu, Takanori Inazumi, Yasuhiro Sogawa, Aapo Hyvarinen, Yoshinobu Kawahara, Takashi Washio, Patrik O Hoyer, Kenneth Bollen, and Patrik Hoyer. Directlingam: A direct method for learning a linear non-gaussian structural equation model. Journal of Machine Learning Research-JMLR, 12(Apr):1225–1248, 2011.
  27. 27.Tomi Silander and Petri Myllym¨aki. A simple approach for finding the globally optimal bayesian network structure. In Proceedings of the Twenty-Second Conference on Uncertainty in Artificial Intelligence, pages 445–452, 2006.
  28. 28.Peter Spirtes, Christopher Meek, and Thomas Richardson. Causal inference in the presence of latent variables and selection bias. In Proceedings of the Eleventh conference on Uncertainty in artificial intelligence, pages 499–506, 1995.
  29. 29.Peter Spirtes, Clark N Glymour, Richard Scheines, and David Heckerman. Causation, prediction, and search. MIT press, 2000.
  30. 30.Ioannis Tsamardinos, Laura E Brown, and Constantin Aliferis. The max-min hill-climbing bayesian network structure learning algorithm. Machine learning, 65:31–78, 2006.
  31. 31.Ruibo Tu, Cheng Zhang, Paul Ackermann, Karthika Mohan, Hedvig Kjellstr¨om, and Kun Zhang. Causal discovery in the presence of missing data. In The 22nd International Conference on Artificial Intelligence and Statistics, pages 1762–1770. PMLR, 2019.
  32. 32.Chirayu (Kong) Wongchokprasitti, Harry Hochheiser, Jeremy Espino, Eamonn Maguire, Bryan Andrews, Michael Davis, and Chris Inskip. bd2kccd/py-causal v1.2.1, December 2019. URL https://doi.org/10.5281/zenodo.3592985.
  33. 33.Feng Xie, Ruichu Cai, Biwei Huang, Clark Glymour, Zhifeng Hao, and Kun Zhang. Generalized independent noise condition for estimating latent variable causal graphs. In NeurIPS, 2020.
  34. 34.Changhe Yuan and Brandon Malone. Learning optimal bayesian networks: A shortest path perspective. Journal of Artificial Intelligence Research, 48:23–65, 2013.
  35. 35.K Zhang and A Hyv¨arinen. On the identifiability of the post-nonlinear causal model. In 25th Conference on Uncertainty in Artificial Intelligence (UAI 2009), pages 647–655. AUAI Press, 2009.
  36. 36.Keli Zhang, Shengyu Zhu, Marcus Kalander, Ignavier Ng, Junjian Ye, Zhitang Chen, and Lujia Pan. gcastle: A python toolbox for causal discovery. arXiv preprint arXiv:2111.15155, 2021.
  37. 37.Kun Zhang, Jonas Peters, Dominik Janzing, and Bernhard Sch¨olkopf. Kernel-based conditional independence test and application in causal discovery. In Proceedings of the Twenty-Seventh Conference on Uncertainty in Artificial Intelligence, pages 804–813, 2011.
  38. 38.Kun Zhang, Shaoan Xie, Ignavier Ng, and Yujia Zheng. Causal representation learning from multiple distributions: A general setting. arXiv preprint arXiv:2402.05052, 2024.
  39. 39.Yujia Zheng and Kun Zhang. Generalizing nonlinear ICA beyond structural sparsity. Advances in Neural Information Processing Systems, 36, 2024.

Citation

MLA
Zheng, Y., et al. “Causal-learn: Causal Discovery in Python”. Journal of Machine Learning Research, vol. 25, no. 60, 2024, pp. 1–8, https://www.jmlr.org/papers/v25/23-0970.html.
APA
Zheng, Y., Huang, B., Chen, W., Ramsey, J., Gong, M., Cai, R., Shimizu, S., Spirtes, P., & Zhang, K. (2024). Causal-learn: Causal Discovery in Python. Journal of Machine Learning Research, 25(60), 1–8. https://www.jmlr.org/papers/v25/23-0970.html
Chicago
Zheng, Y., B. Huang, W. Chen, et al. 2024. “Causal-learn: Causal Discovery in Python”. Journal of Machine Learning Research 25 (60): 1–8. https://www.jmlr.org/papers/v25/23-0970.html.
Harvard
Zheng, Y. et al. (2024) “Causal-learn: Causal Discovery in Python”, Journal of Machine Learning Research, 25(60), pp. 1–8. Available at: https://www.jmlr.org/papers/v25/23-0970.html.
Vancouver
1. Zheng Y, Huang B, Chen W, Ramsey J, Gong M, Cai R, Shimizu S, Spirtes P, Zhang K (2024) Causal-learn: Causal Discovery in Python. Journal of Machine Learning Research 25:1–8

BibTeX

@article{JMLR:v25:23-0970,
  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},
  title   = {Causal-learn: Causal Discovery in Python},
  journal = {Journal of Machine Learning Research},
  year    = {2024},
  volume  = {25},
  number  = {60},
  pages   = {1--8},
  url     = {http://jmlr.org/papers/v25/23-0970.html}
}
Metadata:DOI registry

Source Code

This paper has an official code repository available. Click below to access the source code.

View Repository

Access the Paper

This paper is available from its original source. Click below to access the PDF.

Open PDF
License: https://creativecommons.org/licenses/by/4.0/