Abstract
Research on causal effects often relies on synthetic data due to the scarcity of real-world datasets with ground-truth effects. Since current data-generating tools do not always meet all requirements for state-of-the-art research, ad-hoc methods are often employed. This leads to heterogeneity among datasets and delays research progress. We address the shortcomings of current data-generating libraries by introducing CausalPlayground, a Python library that provides a standardized platform for generating, sampling, and sharing structural causal models (SCMs). CausalPlayground offers fine-grained control over SCMs, interventions, and the generation of datasets of SCMs for learning and quantitative research. Furthermore, by integrating with Gymnasium, the standard framework for reinforcement learning (RL) environments, we enable online interaction with the SCMs. Overall, by introducing CausalPlayground we aim to foster more efficient and comparable research in the field.
Introduction
In the field of causality research, identifying "ground truth" is a significant challenge. To validate whether an algorithm accurately identifies cause-and-effect relationships, researchers require datasets with verified causal links. However, such real-world datasets are exceedingly rare. Consequently, the community relies heavily on synthetic data.
Despite this reliance, the field suffers from significant fragmentation. Most researchers develop ad-hoc data generators, leading to heterogeneity that makes it nearly impossible to compare results across different studies. Existing libraries often lack essential features such as fine-grained control over functional relationships, support for active interventions, or the ability to generate large, controlled sets of models for robust evaluation.
The Need for Standardization
To address these gaps, we identified four core requirements (R1–R4) essential for modern causality research:
- Interventional Data Generation (R1): The ability to perform "do-calculus" style experiments.
- Interaction (R2): Enabling active learning where an agent can intervene and observe results in real-time.
- Fine-grained Control (R3): Allowing researchers to define exact functional relations using Python lambda functions.
- Model Datasets (R4): Moving beyond single-graph testing to large-scale, controlled causal structures.
As shown in the comparison above, CausalPlayground is uniquely positioned to satisfy all these requirements, particularly the need for interactive environments and automated SCM generation.
The CausalPlayground Framework
CausalPlayground is a Python library designed to standardize the generation and sampling of Structural Causal Models (SCMs). A key technical innovation is the SCMEnvironment, which wraps causal models in a Gymnasium (formerly OpenAI Gym) interface. This integration allows reinforcement learning (RL) agents to interact with causal models as dynamic environments, facilitating research in the emerging field of Causal RL.
Unlike tools limited to linear relationships, CausalPlayground’s use of lambda functions allows for modeling complex, non-linear, and physics-based environments. It also functions as a meta-dataset generator, providing tools to create random Directed Acyclic Graphs (DAGs) and both confounded and unconfounded environments.
Experimental Validation and Benchmarking
To demonstrate the library's utility, we conducted a benchmarking study of three popular causal discovery algorithms: PC, GES, and NOTEARS. We generated 30 distinct SCMs, each containing 4 endogenous and 4 exogenous variables, to evaluate performance across different configurations.
The results highlighted the strengths and weaknesses of each approach. While PC and GES performed well on unconfounded data, their performance (F1 and TPR) notably declined when hidden confounders were introduced. NOTEARS showed high performance in specific metrics but demonstrated sensitivity to underlying model assumptions. This experiment confirms that CausalPlayground can successfully automate the entire research pipeline—from model generation to standardized evaluation.
Conclusion and Future Work
CausalPlayground aims to transition causality research from a bespoke craft to a standardized industrial science. While the current version provides a robust foundation, future updates will focus on integrating more diverse models (such as Bayesian networks) and optimizing for GPU parallelization to support high-speed generation of millions of models. Additionally, we aim to extend the library to support high-dimensional, pixel-based environments to further bridge the gap between structured causal models and complex real-world data.
Summary updated