This repository contains the code for our paper When Additive Noise Meets Unobserved Mediators: Bivariate Denoising for Causal Discovery
When using this code, please cite the following:
@inproceedings{
bidd2025,
title={When Additive Noise Meets Unobserved Mediators: Bivariate Denoising Diffusion for Causal Discovery},
author={Dominik Meier and Sujai Hiremath and Promit Ghosal and Kyra Gan},
booktitle={The Thirty-ninth Annual Conference on Neural Information Processing Systems},
year={2025},
url={https://arxiv.org/abs/2503.04556}
}
You can install this package directly:
# Install from source
git clone https://github.com/XPerianer/diffusion-discovery
cd diffusion-discovery
pip install -e .Then use the bidd function in your code. See demo_script for a simple example.
The bidd function takes a config argument for configuring how to run.
Most important options:
epochs: (int) Number of training epochs (default: 2000)hidden_dim: (int) Size of the hidden layers in the neural network (default: 512)num_blocks: (int) Number of residual blocks in the model (default: 2)learning_rate: (float) Learning rate for training (default: 1e-4)train_test_split: (float) Fraction of data used for training (default: 0.8)
For all available options, see diffusion_discovery/simple_interface.py.
For more advanced usages, like reusing of the trained diffusion model, you can use the structure of diffusion_discovery/simple_interface.py, and call the functions themselves.
For our experiments, we used python3.11. We recommend setting up a conda environment:
conda create -n discovery311 python=3.11; conda activate discovery311; conda install pytorch torchvision torchaudio -c pytorch-nightly
Then installing the requirements with:
pip install -r requirements.txtTo install additional requirements for baselines and NPEET, you can run
bash install_requirements.bashThe repository includes automated tests via GitHub Actions:
Verifies that:
- The package installs correctly across Python 3.10-3.11
- The
biddfunction can be imported and executed - The demo script runs successfully
Runs the test suite to verify functionality for data generation:
# Install test dependencies
pip install -e ".[test]"
# Run all tests
pytest
# Reproduce the experimental results for BiDD
We provide three different scripts to run the experiments, which use the `sacred` package to generate test files:
- `experiments/run_diffusion.py` runs BiDD.
- `experiments/run_canm.py` runs CANM.
- `experiments/run_baselines.py` runs the baselines.
To run the experiments for the different mechanism tables, run:
```bash
cd experiments
python run_experiments_mechanism_table.pyTo run the experiments for the depth and sample size tables, run:
cd experiments
python run_experiments_depth_tanh_uniform.py
python run_experiments_sample_size_tanh_uniform.pyTo run the experiments for the Tübingen cause-effect pair, run:
cd experiments
python run_experiments_tuebingen_3000.pyThe experiment scripts generate data in the results folder, which can be analyzed using Jupyter notebook .ipynb files in the experiments/ folder.
Key analysis notebooks include:
experiments/data_analysis_diffusion_mechanism_table.ipynbexperiments/data_analysis_diffusion_depth_table.ipynbexperiments/data_analysis_diffusion_sample_size_table.ipynbexperiments/data_analysis_tuebingen.ipynb