Skip to main content

No project description provided

Project description

Causica CI Build

Causica

Overview

Causal machine learning enables individuals and organizations to make better data-driven decisions. In particular, causal ML allows us to answer “what if” questions about the effect of potential actions on outcomes.

Causal ML is a nascent area, we aim to enable a scalable, flexible, real-world applicable end-to-end causal inference framework. In perticular, we bridge between causal discovery, causal inference, and deep learning to achieve the goal. We aim to develop technology can automate causal decision-making using existing observational data alone, output both the discovered causal relationships and estimate the effect of actions simultaneously.

Causica is a deep learning library for end-to-end causal inference, including both causal discovery and inference. It implements deep end-to-end inference framework [2] and different alternatives.

This project splits the interventional decision making from observational decision making Azua repo found here Azua.

This codebase has been heavily refactored, you can find the previous version of the code here.

[1] Alvarez et al. Simultaneous Missing Value Imputation and Structure Learning with Groups, NeurIPS 2022

[2] Geffner et al. Deep End-to-end Causal Inference.

[3] Gong et al. Rhino: Deep Causal Temporal Relationship Learning With History-dependent Noise, ICLR 2023

[4] Ma et al. Causal Reasoning in the Presence of Latent Confounders via Neural ADMG Learning, ICLR 2023

DECI: End to End Causal Inference

About

Real-world data-driven decision making requires causal inference to ensure the validity of drawn conclusions. However, it is very uncommon to have a-priori perfect knowledge of the causal relationships underlying relevant variables. DECI allows the end user to perform causal inference without having complete knowledge of the causal graph. This is done by combining the causal discovery and causal inference steps in a single model. DECI takes in observational data and outputs ATE and CATE estimates.

For more information, please refer to the paper.

Model Description

DECI is a generative model that employs an additive noise structural equation model (ANM-SEM) to capture the functional relationships among variables and exogenous noise, while simultaneously learning a variational distribution over causal graphs. Specifically, the relationships among variables are captured with flexible neural networks while the exogenous noise is modelled as either a Gaussian or spline-flow noise model. The SEM is reversible, meaning that we can generate an observation vector from an exogenous noise vector through forward simulation and given a observation vector we can recover a unique corresponding exogenous noise vector. In this sense, the DECI SEM can be seen as a flow from exogenous noise to observations. We employ a mean-field approximate posterior distribution over graphs, which is learnt together with the functional relationships among variables by optimising an evidence lower bound (ELBO). Additionally, DECI supports learning under partially observed data.

Simulation-based Causal Inference

DECI estimates causal quantities (ATE) by applying the relevant interventions to its learnt causal graph (i.e. mutilating incoming edges to intervened variables) and then sampling from the generative model. This process involves first sampling a vector of exogenous noise from the learnt noise distribution and then forward simulating the SEM until an observation vector is obtained. ATE can be computed via estimating an expectation over the effect variable of interest using MonteCarlo samples of the intervened distribution of observations.

How to run

The command to train this model the csuite_weak_arrows dataset and evaluate causal discovery and ATE estimation performance is:

python train_csuite_example.py --dataset csuite_weak_arrows

from within examples/csuite_example.

This will download the data from the CSuite Azure blob storage and train DECI on it. See here for more info about CSuite datasets. The script will work on any of the available CSuite datasets.

To evaluate the model run:

python eval_csuite_example.py

This should print various causal discovery and causal inference metrics.

Specifying a noise model

The noise exogenous model can be modified by changing the noise_dist field within training_default.json, either 'gaussian' or 'spline' are allowed.

The Gaussian model has Gaussian exogenous noise distribution with mean set to 0 while its variance is learnt.

The Spline model uses a flexible spline flow that is learnt from the data. This model provides most gains in heavy-tailed noise settings, where the Gaussian model is at risk of overfitting to outliers, but can take longer to train.

Further extensions

For now, we have removed Rhino and DDECI from the codebase but they will be added back. You can still access the previously released versions here.

References

If you have used the models in our code base, please consider to cite the corresponding papers:

[1], (VISL) Pablo Morales-Alvarez, Wenbo Gong, Angus Lamb, Simon Woodhead, Simon Peyton Jones, Nick Pawlowski, Miltiadis Allamanis, Cheng Zhang, "Simultaneous Missing Value Imputation and Structure Learning with Groups", ArXiv preprint

[2], (DECI) Tomas Geffner, Javier Antoran, Adam Foster, Wenbo Gong, Chao Ma, Emre Kiciman, Amit Sharma, Angus Lamb, Martin Kukla, Nick Pawlowski, Miltiadis Allamanis, Cheng Zhang. Deep End-to-end Causal Inference. Arxiv preprint (2022)

[3], (DDECI) Matthew Ashman, Chao Ma, Agrin Hilmkil, Joel Jennings, Cheng Zhang. Causal Reasoning in the Presence of Latent Confounders via Neural ADMG Learning. ICLR (2023)

[4], (Rhino) Wenbo Gong, Joel Jennings, Cheng Zhang, Nick Pawlowski. Rhino: Deep Causal Temporal Relationship Learning with History-dependent Noise. ICLR (2023)

Other references:

  • Louizos, Christos, et al. "Causal effect inference with deep latent-variable models." Advances in neural information processing systems 30 (2017).
  • Hill, Jennifer L. "Bayesian nonparametric modeling for causal inference." Journal of Computational and Graphical Statistics 20.1 (2011): 217-240.

Development

Poetry

We use Poetry to manage the project dependencies, they're specified in the pyproject.toml. To install poetry run:

    curl -sSL https://install.python-poetry.org | python3 -

To install the environment run poetry install, this will create a virtualenv that you can use by running either poetry shell or poetry run {command}. It's also a virtualenv that you can interact with in the normal way too.

More information about poetry can be found here

mlflow

We use mlflow for logging metrics and artifacts. By default it will run locally and store results in ./mlruns.

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

causica-0.1.0.tar.gz (46.7 kB view details)

Uploaded Source

Built Distribution

causica-0.1.0-py3-none-any.whl (63.3 kB view details)

Uploaded Python 3

File details

Details for the file causica-0.1.0.tar.gz.

File metadata

  • Download URL: causica-0.1.0.tar.gz
  • Upload date:
  • Size: 46.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.9.12 Linux/5.10.102.1-microsoft-standard-WSL2

File hashes

Hashes for causica-0.1.0.tar.gz
Algorithm Hash digest
SHA256 be7a14d08b50f4d5c0eed5ad9419ca6c5d4262b65cc8bde7c493ed0b4930c902
MD5 513d1f47bf8d62227eef1fe8e1abe071
BLAKE2b-256 29fe409224afd41a46206718aa53ecec63a507d2caeb4a0881ef9ae75aec5268

See more details on using hashes here.

File details

Details for the file causica-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: causica-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 63.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.9.12 Linux/5.10.102.1-microsoft-standard-WSL2

File hashes

Hashes for causica-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d6f70d7e32349a687df912393f7d994640d8fd5d8a1867a00e706aa6a1d2d84
MD5 9ec258e4a48cb9b2202f516a0ddc96c5
BLAKE2b-256 2aa2ba330fc546d6a6d705435d52b05f05c19dc5b103a65157c654358a6eb88c

See more details on using hashes here.

Supported by

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