All Projects → phlippe → ENCO

phlippe / ENCO

Licence: other
Official repository of the paper "Efficient Neural Causal Discovery without Acyclicity Constraints"

Programming Languages

python
139335 projects - #7 most used programming language
Jupyter Notebook
11667 projects
shell
77523 projects

Projects that are alternatives of or similar to ENCO

causal-learn
Causal Discovery for Python. Translation and extension of the Tetrad Java code.
Stars: ✭ 428 (+723.08%)
Mutual labels:  causality, causal-discovery
RECCON
This repository contains the dataset and the PyTorch implementations of the models from the paper Recognizing Emotion Cause in Conversations.
Stars: ✭ 126 (+142.31%)
Mutual labels:  causality
invariant-risk-minimization
Implementation of Invariant Risk Minimization https://arxiv.org/abs/1907.02893
Stars: ✭ 76 (+46.15%)
Mutual labels:  causality
causal-ml
Must-read papers and resources related to causal inference and machine (deep) learning
Stars: ✭ 387 (+644.23%)
Mutual labels:  causal-discovery
causeinfer
Machine learning based causal inference/uplift in Python
Stars: ✭ 45 (-13.46%)
Mutual labels:  causality
pycid
Library for graphical models of decision making, based on pgmpy and networkx
Stars: ✭ 64 (+23.08%)
Mutual labels:  causality
cfvqa
[CVPR 2021] Counterfactual VQA: A Cause-Effect Look at Language Bias
Stars: ✭ 96 (+84.62%)
Mutual labels:  causality
ACE
Code for our paper, Neural Network Attributions: A Causal Perspective (ICML 2019).
Stars: ✭ 47 (-9.62%)
Mutual labels:  causality
cfml tools
My collection of causal inference algorithms built on top of accessible, simple, out-of-the-box ML methods, aimed at being explainable and useful in the business context
Stars: ✭ 24 (-53.85%)
Mutual labels:  causality
Dowhy
DoWhy is a Python library for causal inference that supports explicit modeling and testing of causal assumptions. DoWhy is based on a unified language for causal inference, combining causal graphical models and potential outcomes frameworks.
Stars: ✭ 3,480 (+6592.31%)
Mutual labels:  causality
causaldag
Python package for the creation, manipulation, and learning of Causal DAGs
Stars: ✭ 82 (+57.69%)
Mutual labels:  causality
Scribe-py
Regulatory networks with Direct Information in python
Stars: ✭ 28 (-46.15%)
Mutual labels:  causality
CREST
A Causal Relation Schema for Text
Stars: ✭ 19 (-63.46%)
Mutual labels:  causality
Causal-Deconvolution-of-Networks
Causal Deconvolution of Networks by Algorithmic Generative Models
Stars: ✭ 25 (-51.92%)
Mutual labels:  causality
iPerceive
Applying Common-Sense Reasoning to Multi-Modal Dense Video Captioning and Video Question Answering | Python3 | PyTorch | CNNs | Causality | Reasoning | LSTMs | Transformers | Multi-Head Self Attention | Published in IEEE Winter Conference on Applications of Computer Vision (WACV) 2021
Stars: ✭ 52 (+0%)
Mutual labels:  causality
Causal Reading Group
We will keep updating the paper list about machine learning + causal theory. We also internally discuss related papers between NExT++ (NUS) and LDS (USTC) by week.
Stars: ✭ 339 (+551.92%)
Mutual labels:  causality
Awesome-Neural-Logic
Awesome Neural Logic and Causality: MLN, NLRL, NLM, etc. 因果推断,神经逻辑,强人工智能逻辑推理前沿领域。
Stars: ✭ 106 (+103.85%)
Mutual labels:  causality
Generalization-Causality
关于domain generalization,domain adaptation,causality,robutness,prompt,optimization,generative model各式各样研究的阅读笔记
Stars: ✭ 482 (+826.92%)
Mutual labels:  causality
Pgmpy
Python Library for learning (Structure and Parameter) and inference (Probabilistic and Causal) in Bayesian Networks.
Stars: ✭ 1,942 (+3634.62%)
Mutual labels:  structure-learning
spyn
Sum-Product Network learning routines in python
Stars: ✭ 21 (-59.62%)
Mutual labels:  structure-learning

Efficient Neural Causal Discovery without Acyclicity Constraints

Short paper | Long paper | Poster | Tutorial Open filled In Collab

This is the official repository of the paper Efficient Neural Causal Discovery without Acyclicity Constraints by Phillip Lippe, Taco Cohen, and Efstratios Gavves. Presented at the International Conference on Learning Representations (ICLR), 2022.

Paper summary

Learning the structure of a causal graphical model using both observational and interventional data is a fundamental problem in many scientific fields. A promising direction is continuous optimization for score-based methods, which efficiently learn the causal graph in a data-driven manner. However, to date, those methods require slow constrained optimization to enforce acyclicity or lack convergence guarantees. In this work, we present ENCO, an efficient structure learning method leveraging observational and interventional data. ENCO formulates the graph search as an optimization of independent edge likelihoods with the edge orientation being modeled as a separate parameter. Consequently, we can provide convergence guarantees of ENCO under mild conditions without constraining the score function with respect to acyclicity. In experiments, we show that ENCO handles various graph settings well, and even recovers graphs with up to 1,000 nodes in less than nine hours of compute using a single GPU (NVIDIA RTX3090) while having less than one mistake on average out of 1 million possible edges. Further, ENCO can handle and detect latent confounders.

Requirements

The code is written in PyTorch (1.9) and Python 3.8. Higher versions of PyTorch and Python are expected to work as well.

We recommend to use conda for installing the requirements. If you haven't installed conda yet, you can find instructions here. The steps for installing the requirements are:

  1. Create a new environment from the provided YAML file:

    conda env create -f environment.yml
    

    The environment installs PyTorch with CUDA 11.1. Adjust the CUDA version if you want to install it with CUDA 10.2, or remove it from the environment file if you want to install it on a CPU-only system.

  2. Activate the environment

    conda activate enco
    

Datasets

To reproduce the experiments in the paper, we provide datasets of causal graphs for the synthetic, confounder, and real-world experiments. The datasets can be download by executing download_datasets.sh (requires approx. 600MB disk space). Alternatively, the datasets can be accessed through this link (unzip the file in the causal_graphs folder).

Running experiments

The repository is structured in three main folders:

  • causal_graphs contains all utilities for creating, visualizing and handling causal graphs that we experiment on.
  • causal_discovery contains the code of ENCO for structure learning.
  • experiments contains all utilities to run experiments with ENCO on various causal graphs.

Details on running experiments as well as the commands for reproducing the experiments in the paper can be found in the experiments folder.

Simple example

We created a quick walkthrough tutorial that goes through the most important functions/components in the repository in walkthrough.ipynb. In short, ENCO can be applied as follows:

from causal_graphs.graph_generation import generate_categorical_graph, get_graph_func  # Functions for generating new graphs
from causal_discovery.enco import ENCO

# Create a graph on which ENCO should be applied
graph = generate_categorical_graph(num_vars=8, 
                                   min_categs=10,
                                   max_categs=10,
                                   graph_func=get_graph_func('random'),
                                   edge_prob=0.4,
                                   seed=42)

# Create ENCO object
enco_module = ENCO(graph=graph)
if torch.cuda.is_available():
    enco_module.to(torch.device('cuda:0'))

# Run causal discovery
predicted_adj_matrix = enco_module.discover_graph(num_epochs=10)

FAQ

How is the repository structured?

We give a quick walkthrough of the most important functions/components in the repository in walkthrough.ipynb.

Can I also run the experiments on my CPU?

Yes, a GPU is not a strict constraint to run ENCO. Especially for small graphs (about 10 variables), ENCO is similarly fast on a multi-core CPU than on a GPU. To speed up experiments for small graphs on a CPU, it is recommended to reduce the hidden size from 64 to 32, and the graph samples in graph fitting from 100 to 20.

How can I apply ENCO to my own dataset?

If your causal graph/dataset is specified in a .bif format as the real-world graphs, you can directly start an experiment on it using experiments/run_exported_graphs.py. The alternative format is a .npz file which contains a observational and interventional dataset. The file needs to contain the following keys:

  • data_obs: A dataset of observational samples. This array must be of shape [M, num_vars] where M is the number of data points. For categorical data, it should be any integer data type (e.g. np.int32 or np.uint8).
  • data_int: A dataset of interventional samples. This array must be of shape [num_vars, K, num_vars] where K is the number of data points per intervention. The first axis indicates the variables on which has been intervened to gain this dataset.
  • adj_matrix: The ground truth adjacency matrix of the graph (shape [num_vars, num_vars], type bool or integer). The matrix is used to determine metrics like SHD during/after training. If the ground truth matrix is not known, you can submit a zero-matrix (keep in mind that the metrics cannot be used in this case).
Can I apply ENCO to continuous or categorical data?

Both data types are supported in this repository. Simply make sure that the numpy array has the data type np.float32 for continuous experiments, and np.uint8 or np.int32 for categorical data.

Citation

If you use this code, please consider citing our work:

@inproceedings{lippe2022enco,
 author = {Lippe, Phillip and Cohen, Taco and Gavves, Efstratios},
 booktitle = {International Conference on Learning Representations},
 title = {Efficient Neural Causal Discovery without Acyclicity Constraints},
 url = {https://openreview.net/forum?id=eYciPrLuUhG},
 year = {2022}
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].