|
| 1 | +# A Fixed-Point Approach for Causal Generative Modeling (FiP) |
| 2 | +[ |
| 3 | +](https://arxiv.org/pdf/2404.06969) |
| 4 | + |
| 5 | +This repo implements FiP proposed in the ICML 2024 paper "A Fixed-Point Approach for Causal Generative Modeling". |
| 6 | + |
| 7 | +FiP is a transformer-based approach to learn Structural Causal Models (SCMs) from observational data. To do so, FiP uses an equivalent formulation of SCMs that does not require Directed Acyclic Graphs (DAGs), viewed as fixed-point problems on the causally ordered variables. To infer topological orders (TOs), we propose to amortize the learning of a TO inference method on synthetically generated datasets by sequentially predicting the leaves of graphs seen during training. |
| 8 | + |
| 9 | +## Dependency |
| 10 | +We use [Poetry](https://python-poetry.org/) to manage the project dependencies, they are specified in [pyproject](pyproject.toml) file. To install poetry, run: |
| 11 | + |
| 12 | +```console |
| 13 | + curl -sSL https://install.python-poetry.org | python3 - |
| 14 | +``` |
| 15 | +To install the environment, run `poetry install` in the directory of fip project. |
| 16 | + |
| 17 | +## Prepare the data |
| 18 | +To reproduce the results obtained in the [paper](https://arxiv.org/pdf/2404.06969), you need to generate the data. A more detailed explanation on how to generate the data can be found in [README.md](src/fip/data_generation/README.md). |
| 19 | + |
| 20 | +### AVICI / Csuite / Causal NF data generation |
| 21 | +To generate the [AVICI](https://arxiv.org/abs/2205.12934) synthetic data, run the following command: |
| 22 | +```console |
| 23 | + bash src/fip/data_generation/avici_data.sh |
| 24 | +``` |
| 25 | +This executes the [avici_data.py](src/fip/dataset_generation/avici_data.py) file to generate various datasets from the dataset distributions presented in [AVICI](https://arxiv.org/abs/2205.12934). The generated data will be saved in the `src/fip/data`. |
| 26 | + |
| 27 | +Similarly, to generate the [CSuite](https://arxiv.org/abs/2202.02195) and the [Causal NF](https://arxiv.org/abs/2306.05415) synthetic data, run the following commands: |
| 28 | +```console |
| 29 | + bash src/fip/data_generation/csuite_data.sh |
| 30 | + bash src/fip/data_generation/normalizing_data.sh |
| 31 | +``` |
| 32 | + |
| 33 | +## Run experiments |
| 34 | +In the [launchers](src/fip/launchers) directory, we provide scripts to run the experiments reported in the paper. A more detailed explanation on how to use these files can be found in [README.md](src/fip/launchers/README.md). |
| 35 | + |
| 36 | + |
| 37 | +### Zero-Shot Inference of TOs |
| 38 | +To train the TO inference method on AVICI data, run the following command: |
| 39 | +```console |
| 40 | + python -m fip.launchers.amortization |
| 41 | +``` |
| 42 | +The model as well as the config file will be saved in `src/fip/outputs`. |
| 43 | + |
| 44 | + |
| 45 | +### Learn FiP with (Partial) Causal Knowledge |
| 46 | +To train FiP when the DAG is known, run the following command: |
| 47 | +```console |
| 48 | + python -m fip.launchers.scm_learning_with_ground_truth |
| 49 | + --ground_truth_case graph |
| 50 | + --standardize |
| 51 | +``` |
| 52 | +The model as well as the config file will be saved in `src/fip/outputs`. If you want to train FiP, when only the TO is known, replace `--ground_truth_case graph` with `--ground_truth_case perm`. These commands assume that the datasets have been generated and saved in `src/fip/data`. |
| 53 | + |
| 54 | + |
| 55 | +### Learn FiP End-to-End |
| 56 | +To train FiP end-to-end, run the following command: |
| 57 | +```console |
| 58 | + python -m fip.launchers.scm_learning_with_predicted_truth |
| 59 | + --run_id <name_of_the_directory_containing_the_amortized_model> |
| 60 | + --standardize |
| 61 | +``` |
| 62 | +The model as well as the config file will be saved in `src/fip/outputs`. This command assumes that a TO inference model has been trained and saved in a directory located at `src/fip/outputs/<name_of_the_directory_containing_the_amortized_model>`. This command also assumes that the datasets have been generated and saved in `src/fip/data`. |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | +``` |
0 commit comments