Causal-learn: Causal Discovery in Python

Yujia Zheng, Biwei Huang, Wei Chen, Joseph D. Ramsey, Mingming Gong, Ruichu Cai, Shohei Shimizu, Peter Spirtes, Kun Zhang

TL;DR

This paper introduces causal-learn, a comprehensive, open-source Python library for causal discovery. It aims to democratize causal discovery by providing a unified platform with easy-to-use APIs, modular building blocks, and extensive documentation for a wide range of algorithms, making it accessible to both practitioners and researchers.

What Problem Does This Paper Address?

Uncovering causal relationships from observational data is crucial across many scientific fields, from genomics to epidemiology, as traditional experimental methods can be costly or impractical. While various causal discovery algorithms exist, they are often scattered across different programming languages (like R and Java) or specialized toolkits, creating a barrier for researchers and practitioners who prefer Python. This fragmentation hinders accessibility, integration into existing Python-based workflows, and the development of new methods. causal-learn addresses this by providing a single, Python-native library that consolidates a broad spectrum of causal discovery techniques.

Methods

causal-learn categorizes its methods into four main types:

  • Constraint-based causal discovery: These methods, like PC and FCI, rely on conditional independence tests to infer causal structures.
  • Score-based causal discovery: Algorithms such as GES use a scoring function to find the best-fitting causal graph.
  • Functional Causal Models (FCMs)-based: These methods, including ANM and LiNGAM, leverage assumptions about the functional relationships between variables and noise distributions to identify causal directions, often distinguishing between graphs within the same Markov equivalence class.
  • Causal representation learning: This category includes methods like GIN that focus on learning causal structures, potentially with latent variables.

Beyond these core algorithms, causal-learn offers a suite of utilities for graph operations (handling DAGs, CPDAGs, PAGs, etc.) and evaluation metrics (precision, recall, Structural Hamming Distance). A key methodological aspect is its full implementation in Python, eliminating external dependencies on Java or R, which is a significant advantage for the Python-centric machine learning community.

Datasets

The paper mentions that causal-learn includes a collection of well-tested benchmark datasets. These are provided to aid in the evaluation of causal discovery methods, as ground-truth causal relations are often unknown for real-world data. The library also includes functions to import these datasets. Specific details about newly introduced benchmarks or how they differ from existing ones are not elaborated upon in the provided text.

Key Insights and Ideas

  • Python-Native Ecosystem: The most significant insight is the creation of a comprehensive causal discovery library fully implemented in Python. This directly addresses the growing preference for Python in machine learning and data science, simplifying integration and development.
  • Democratization of Causal Discovery: By offering easy-to-use APIs, modular components, and thorough documentation, causal-learn aims to make advanced causal discovery techniques accessible to a wider audience, including those who are not causal inference specialists.
  • Unified Platform: Consolidating diverse causal discovery methods (constraint-based, score-based, FCMs, etc.) into a single library reduces the fragmentation that previously existed, making it easier for users to explore and compare different approaches.
  • Extensibility: The modular design encourages users to develop and integrate their own methods, fostering community contributions and the advancement of the field.

Key Results

The paper primarily describes the library's features and design rather than presenting empirical results from experiments. The key "result" is the successful development and release of the causal-learn library itself, which offers:

  • A comprehensive collection of causal discovery algorithms across major categories.
  • Modular building blocks for developers.
  • Detailed documentation for learners.
  • Easy-to-use APIs for practitioners.
  • Full implementation in Python, removing Java/R dependencies.

The paper highlights that the library is under active development and aims to incorporate the latest advancements in the field.

Limitations and Future Work

  • Active Development: The library is described as being under "active development," implying that it is continuously evolving and may still be adding features or refining existing ones.
  • Benchmark Datasets: While benchmark datasets are included, the paper notes that evaluating causal discovery methods is "notoriously known to be hard," suggesting that further work on robust evaluation and more diverse, realistic benchmark datasets would be beneficial.
  • Integration with other tools: The paper mentions the convenience of using causal-learn with inference packages like DoWhy and Ananke for end-to-end causal pipelines, hinting at future work in seamless integration and workflow development.
  • Community Contribution: The authors emphasize the importance of community contributions, suggesting that future work will involve expanding the library's capabilities through collaborative efforts.

Summary updated

BibTeX
@article{zheng2024causal,
  author = {Yujia Zheng and Biwei Huang and Wei Chen and Joseph D. Ramsey and Mingming Gong and Ruichu Cai and Shohei Shimizu and Peter Spirtes and Kun Zhang},
  title = {{Causal-learn: Causal Discovery in Python}},
  journal = {J. Mach. Learn. Res.},
  year = {2024},
  url = {https://openreview.net/forum?id=wXBWWTmYo3},
}
Figure