Code Monkey home page Code Monkey logo

core's Introduction

CORE: Towards Scalable and Efficient Causal Discovery with Reinforcement Learning

📖full paper

Abstract

Causal discovery is the challenging task of inferring causal structure from data. Motivated by Pearl's Causal Hierarchy (PCH), which tells us that passive observations alone are not enough to distinguish correlation from causation, there has been a recent push to incorporate interventions into machine learning research. Reinforcement learning provides a convenient framework for such an active approach to learning. This paper presents CORE, a deep reinforcement learning-based approach for causal discovery and intervention planning. CORE learns to sequentially reconstruct causal graphs from data while learning to perform informative interventions. Our results demonstrate that CORE generalizes to unseen graphs and efficiently uncovers causal structures. Furthermore, CORE scales to larger graphs with up to 10 variables and outperforms existing approaches in structure estimation accuracy and sample efficiency.

This repository contains all code and data to train a CORE model. Furthermore, it contains the trained models that are presented in the paper and instruction on how to reproduce the results.

Installation Requirements

To run this codebase you need the following requirements:

  • Python 3.9
  • Pytorch (version 1.13 + CUDA 11.7)
  • Wandb 0.14.2

Additionally, make sure to pip install -r requirements.txt

Training Data

You can find the graphs on which our models were trained and tested in the "data/" folder. The functions that were used to sample the SCMs from these graphs can be found in "envs/generation/functions.py". For adding new functions, simply define one in this file. Make sure to also add the new function to the set of possible functions in the "scm_gen.py" file.

You can also generate your own graphs data by running the "generate_graph_data.py" script. For example, to a dataset of 1000 training graphs and 100 testing graphs with 5 variables, you can run:

python generate_graph_data.py --n-train-graphs 1000 --n-test-graphs 100 --n-endo 5 --method ER --edge-probability 0.2 --save-dir [PATH]

Trained Models

The models that were trained in the paper can be found in the "exp/" folder. The folder name within the folder that defines the graph size, tells you which function the model was trained on. E.g. "exp/5var/lin_nonoise_20 contains the model that was trained on SCMs with linear-additive functions, no noise, and an intervention value of 20.

To test these models, modify the data-paths in "evaluation.py", to load the model you are interested in.

Training your own Model

You can train your own model with the "train.py" scipt as follows:

python train.py --possible-functions linear --total-steps 1000000 --ep-length 5 --interv-value 20 --test-set [PATH] --save-dir [SAVE_PATH] --train-set [PATH]

Where --possible-functions defines the function classes on which to train, --ep-length the number of steps/samples per SCM, and --interv-value the values for each hard intervention. --test-set and --train-set are the path to the test and train set of DAGs, respectively. Make sure to also check the other parameters to influence your training behaviour/performance.

Citing this Work

If you use this code for your own work, please consider citing us:

@inproceedings{sauter2024CORE,
  title={CORE: Towards Scalable and Efficient Causal Discovery with Reinforcement Learning},
  author={Sauter, Andreas and Botteghi, Nicolò, and Acar, Erman and Plaat, Aske},
  booktitle={Proceedings of the 2024 International Conference on Autonomous Agents and Multiagent Systems},
  year={2024}
}

core's People

Contributors

sa-and avatar

Stargazers

 avatar 李文浩 avatar Md Musfiqur Rahman avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.