{"id":19199810,"url":"https://github.com/rose-stl-lab/mcd","last_synced_at":"2025-05-09T01:25:57.968Z","repository":{"id":245616190,"uuid":"805593672","full_name":"Rose-STL-Lab/MCD","owner":"Rose-STL-Lab","description":"Implementation of the ICML 2024 paper \"Discovering Mixtures of Structural Causal Models from Time Series Data\"","archived":false,"fork":false,"pushed_at":"2024-10-30T16:55:56.000Z","size":497,"stargazers_count":21,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T20:23:30.665Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rose-STL-Lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-24T23:43:20.000Z","updated_at":"2025-03-26T12:40:16.000Z","dependencies_parsed_at":"2024-06-23T02:45:03.673Z","dependency_job_id":"01eb7e5a-74d8-48e0-a7dd-9d961b5a9f29","html_url":"https://github.com/Rose-STL-Lab/MCD","commit_stats":null,"previous_names":["rose-stl-lab/mcd"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rose-STL-Lab%2FMCD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rose-STL-Lab%2FMCD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rose-STL-Lab%2FMCD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rose-STL-Lab%2FMCD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rose-STL-Lab","download_url":"https://codeload.github.com/Rose-STL-Lab/MCD/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253172997,"owners_count":21865605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T12:29:04.539Z","updated_at":"2025-05-09T01:25:57.910Z","avatar_url":"https://github.com/Rose-STL-Lab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Discovering Mixtures of Structural Causal Models from Time Series Data\n\nImplementation of the paper \"Discovering Mixtures of Structural Causal Models from Time Series Data\", to appear at ICML 2024, Vienna.\n\nMixture Causal Discovery (MCD) aims to infer multiple causal graphs from time-series data. \n\n\u003cdiv style=\"text-align: center;\"\u003e\n  \u003cimg src=\"assets/overview_fig.png\" alt=\"Overview\" style=\"width: 50%;\"\u003e\n  \u003cp\u003e\u003cem\u003eModel Overview\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv style=\"text-align: center;\"\u003e\n  \u003cimg src=\"assets/snp100_results.png\" alt=\"S\u0026P100 Results\" style=\"width: 50%;\"\u003e\n  \u003cp\u003e\u003cem\u003eResults on the S\u0026P100 dataset\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\n\n## Requirements\n\n- NVIDIA GPU with minimum CUDA 11.8 installed.\n- Make sure you have `conda` installed.\n\n## Setup\n\nCreate a conda environment and install the prerequisite packages:\n```\nconda create -n mcd python=3.9 -y \u0026\u0026 \\\nconda run --no-capture-output -n mcd pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 \u0026\u0026 \\\nconda run --no-capture-output -n mcd pip3 install lightning matplotlib numpy scikit-learn seaborn \\\n    cdt wandb igraph pyro-ppl hydra-core yahoofinancials \u0026\u0026 \\\n```\n\nYou also need the `graphviz` library. This library can be installed on Ubuntu systems using the command:\n```\nsudo apt-get install -y git \u0026\u0026 \\\nsudo apt-get install -y graphviz graphviz-dev\n```\n\nFor baselines:\n```\nconda create -n baselines python=3.8 -y \u0026\u0026 \\\nconda run --no-capture-output -n baselines pip3 install pygraphviz wandb tigramite hydra-core pyro-ppl lightning causalnex matplotlib cdt seaborn lingam\n```\n\n\n## Dataset generation\n\nGenerate the datasets using the script files in the `scripts/` folder.\n\n- Linear synthetic dataset: Run `./scripts/generate_synthetic_datasets_linear.sh`\n- Nonlinear synthetic dataset: Run `./scripts/generate_synthetic_datasets_nonlinear.sh`\n- Netsim datasets: Run `./scripts/setup_netsim.sh`\n- DREAM3: Run `./scripts/setup_dream3.sh`\n- S\u0026P100: Run `./scripts/generate_snp100.sh`\n\n## Running the code\n\nChange the name of the `wandb` project in the config file.\n\n- Linear synthetic dataset: Run `python3 -m src.train +dataset=ER_ER_num_graphs_\u003cK\u003e_lag_2_dim_\u003cD\u003e_NoHistDep_0.5_linear_gaussian_con_1_seed_0_n_samples_1000 +synthetic=mcd_linear`. Change `\u003cD\u003e` and `\u003cK\u003e` to the correct setting.  \n- Nonlinear synthetic dataset: Run `python3 -m src.train +dataset=ER_ER_num_graphs_\u003cK\u003e_lag_2_dim_\u003cD\u003e_HistDep_0.5_mlp_spline_product_con_1_seed_0_n_samples_1000 +synthetic=mcd`. Change `\u003cD\u003e` and `\u003cK\u003e` to the correct setting.  \n- Netsim-mixture: Run `python3 -m src.train +dataset=netsim_15_200_permuted +netsim=mcd`\n- DREAM3: Run `python3 -m src.train +dataset=dream3 +dream3=mcd`\n- S\u0026P100: Run `python3 -m src.train +dataset=snp100 +snp100=mcd`\n\nResults are stored in the `results/` folder.\n\n## Acknowledgement\n\nWe implemented some parts of our framework using code from [Project Causica](https://github.com/microsoft/causica).\n\n## Citation\n\nIf you find this work useful, please consider citing us.\n\n```\n@inproceedings{varambally2024discovering,\n  author       = {Varambally, Sumanth and Ma, Yi-An and Yu, Rose},\n  title        = {Discovering Mixtures of Structural Causal Models from Time Series Data},\n  booktitle    = {International Conference on Machine Learning, {ICML} 2024},\n  series       = {Proceedings of Machine Learning Research},\n  year         = {2024}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frose-stl-lab%2Fmcd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frose-stl-lab%2Fmcd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frose-stl-lab%2Fmcd/lists"}