{"id":13788800,"url":"https://github.com/liyaguang/DCRNN","last_synced_at":"2025-05-12T03:30:49.411Z","repository":{"id":48165260,"uuid":"113516939","full_name":"liyaguang/DCRNN","owner":"liyaguang","description":"Implementation of Diffusion Convolutional Recurrent Neural Network in Tensorflow","archived":false,"fork":false,"pushed_at":"2024-12-09T17:40:10.000Z","size":131010,"stargazers_count":1218,"open_issues_count":26,"forks_count":402,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-12-09T18:37:36.985Z","etag":null,"topics":["deep-learning-graphs","iclr2018","spatiotemporal-forecasting","time-series","traffic-data"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liyaguang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-08T01:32:19.000Z","updated_at":"2024-12-09T17:40:15.000Z","dependencies_parsed_at":"2022-09-09T13:40:34.405Z","dependency_job_id":null,"html_url":"https://github.com/liyaguang/DCRNN","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyaguang%2FDCRNN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyaguang%2FDCRNN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyaguang%2FDCRNN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyaguang%2FDCRNN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liyaguang","download_url":"https://codeload.github.com/liyaguang/DCRNN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253667942,"owners_count":21944943,"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":["deep-learning-graphs","iclr2018","spatiotemporal-forecasting","time-series","traffic-data"],"created_at":"2024-08-03T21:00:53.757Z","updated_at":"2025-05-12T03:30:44.395Z","avatar_url":"https://github.com/liyaguang.png","language":"Python","funding_links":[],"categories":["TensorFlow Implementations"],"sub_categories":[],"readme":"# Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting\n\n![Diffusion Convolutional Recurrent Neural Network](figures/model_architecture.jpg \"Model Architecture\")\n\nThis is a TensorFlow implementation of Diffusion Convolutional Recurrent Neural Network in the following paper: \\\nYaguang Li, Rose Yu, Cyrus Shahabi, Yan Liu, [Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting](https://arxiv.org/abs/1707.01926), ICLR 2018.\n\n## Requirements\n- scipy\u003e=0.19.0\n- numpy\u003e=1.12.1\n- pandas\u003e=0.19.2\n- pyaml\n- statsmodels\n- tensorflow\u003e=1.3.0\n\n\nDependency can be installed using the following command:\n```bash\npip install -r requirements.txt\n```\n\n## Data Preparation\nThe traffic data files for Los Angeles (METR-LA) and the Bay Area (PEMS-BAY), i.e., `metr-la.h5` and `pems-bay.h5`, are available at [Google Drive](https://drive.google.com/open?id=10FOTa6HXPqX8Pf5WRoRwcFnW9BrNZEIX) or [Baidu Yun](https://pan.baidu.com/s/14Yy9isAIZYdU__OYEQGa_g), and should be\nput into the `data/` folder.\nThe `*.h5` files store the data in `panads.DataFrame` using the `HDF5` file format. Here is an example:\n\n|                     | sensor_0 | sensor_1 | sensor_2 | sensor_n |\n|:-------------------:|:--------:|:--------:|:--------:|:--------:|\n| 2018/01/01 00:00:00 |   60.0   |   65.0   |   70.0   |    ...   |\n| 2018/01/01 00:05:00 |   61.0   |   64.0   |   65.0   |    ...   |\n| 2018/01/01 00:10:00 |   63.0   |   65.0   |   60.0   |    ...   |\n|         ...         |    ...   |    ...   |    ...   |    ...   |\n\n\nHere is an article about [Using HDF5 with Python](https://medium.com/@jerilkuriakose/using-hdf5-with-python-6c5242d08773).\n\nRun the following commands to generate train/test/val dataset at  `data/{METR-LA,PEMS-BAY}/{train,val,test}.npz`.\n```bash\n# Create data directories\nmkdir -p data/{METR-LA,PEMS-BAY}\n\n# METR-LA\npython -m scripts.generate_training_data --output_dir=data/METR-LA --traffic_df_filename=data/metr-la.h5\n\n# PEMS-BAY\npython -m scripts.generate_training_data --output_dir=data/PEMS-BAY --traffic_df_filename=data/pems-bay.h5\n```\n\n## Graph Construction\n As the currently implementation is based on pre-calculated road network distances between sensors, it currently only\n supports sensor ids in Los Angeles (see `data/sensor_graph/sensor_info_201206.csv`).\n```bash\npython -m scripts.gen_adj_mx  --sensor_ids_filename=data/sensor_graph/graph_sensor_ids.txt --normalized_k=0.1\\\n    --output_pkl_filename=data/sensor_graph/adj_mx.pkl\n```\nBesides, the locations of sensors in Los Angeles, i.e., METR-LA, are available at [data/sensor_graph/graph_sensor_locations.csv](https://github.com/liyaguang/DCRNN/blob/master/data/sensor_graph/graph_sensor_locations.csv), and the locations of sensors in PEMS-BAY are available at [data/sensor_graph/graph_sensor_locations_bay.csv](https://github.com/liyaguang/DCRNN/blob/master/data/sensor_graph/graph_sensor_locations_bay.csv).\n\n## Run the Pre-trained Model on METR-LA\n\n```bash\n# METR-LA\npython run_demo.py --config_filename=data/model/pretrained/METR-LA/config.yaml\n\n# PEMS-BAY\npython run_demo.py --config_filename=data/model/pretrained/PEMS-BAY/config.yaml\n```\nThe generated prediction of DCRNN is in `data/results/dcrnn_predictions`.\n\n\n## Model Training\n\nHere are commands for training the model on `METR-LA` and `PEMS-BAY` respectively. \n\n```bash\n# METR-LA\npython dcrnn_train.py --config_filename=data/model/dcrnn_la.yaml\n\n# PEMS-BAY\npython dcrnn_train.py --config_filename=data/model/dcrnn_bay.yaml\n```\n### Training details and tensorboard links\nWith a single GTX 1080 Ti, each epoch takes around 5min for `METR-LA`, and 13 min for `PEMS-BAY` respectively. Here are example tensorboard links for [DCRNN on METR-LA](https://tensorboard.dev/experiment/ijwg04waSOWQ2Pj4mZ3tAg), [DCRNN on PEMS-BAY](https://tensorboard.dev/experiment/QzJtnMfgQJCQ7vc7wNJjxg), including training details and metrics over time.\n\nNote that, there is a chance of training loss explosion, one temporary workaround is to restart from the last saved model before the explosion, or to decrease the learning rate earlier in the learning rate schedule. \n\n### Metric for different horizons and datasets\nThe following table summarizes the performance of DCRNN on two dataset with regards to different metrics and horizons (numbers are better than those reported in the paper due to bug fix in commit [2e4b8c8](https://github.com/liyaguang/DCRNN/commit/2e4b8c868fd410a1fb4a469f0995de6616115e03) on Oct 1, 2018).\n\n| Dataset  | Metric | 5min  | 15min | 30min | 60min  |\n|----------|--------|-------|-------|-------|--------|\n| METR-LA  | MAE    | 2.18  | 2.67  | 3.08  | 3.56   |\n|          | MAPE   | 5.17% | 6.84% | 8.38% | 10.30% |\n|          | RMSE   | 3.77  | 5.17  | 6.3   | 7.52   |\n| PEMS-BAY | MAE    | 0.85  | 1.31  | 1.66  | 1.98   |\n|          | MAPE   | 1.63% | 2.74% | 3.76% | 4.74%  |\n|          | RMSE   | 1.54  | 2.76  | 3.78  | 4.62   |\n\n\n## Eval baseline methods\n```bash\n# METR-LA\npython -m scripts.eval_baseline_methods --traffic_reading_filename=data/metr-la.h5\n```\nMore details are being added ...\n\n\n## Deploying DCRNN on Large Graphs with graph partitioning\n\nWith graph partitioning, DCRNN has been successfully deployed to forecast the traffic of the entire California highway network with **11,160** traffic sensor locations simultaneously. The general idea is to partition the large highway network into a number of small networks, and trained them with a share-weight DCRNN simultaneously. The training process takes around 3 hours in a moderately sized GPU cluster, and the real-time inference can be run on traditional hardware such as CPUs.\n\nSee the [paper](https://arxiv.org/pdf/1909.11197.pdf \"GRAPH-PARTITIONING-BASED DIFFUSION CONVOLUTION RECURRENT NEURAL NETWORK FOR LARGE-SCALE TRAFFIC FORECASTING\"), [slides](https://press3.mcs.anl.gov/atpesc/files/2019/08/ATPESC_2019_Track-8_11_8-9_435pm_Mallick-DCRNN_for_Traffic_Forecasting.pdf), and [video](https://www.youtube.com/watch?v=liJNNtJGTZU\u0026list=PLGj2a3KTwhRapjzPcxSbo7FxcLOHkLcNt\u0026index=10) by Tanwi Mallick et al. from Argonne National Laboratory for more information.\n\n## DCRNN Applications \nIn addition to vehicle traffic forecasting, DCRNN and its variants have been applied in many important domains, including:\n* Neuroimaging: causal inference in brain networks. [S. Wein et al. A graph neural network framework for causal inference in brain networks. Scientific Reports, 2021](https://www.nature.com/articles/s41598-021-87411-8), GitHub [Repo](https://github.com/simonvino/DCRNN_brain_connectivity).\n* Air quality forecasting: [Y Lin et al. Exploiting spatiotemporal patterns for accurate air quality forecasting using deep learning. ACM SIGSPATIAL 2018](https://dl.acm.org/doi/10.1145/3274895.3274907).\n* Internet traffic forecasting: [D. Andreoletti et al. Network traffic prediction based on diffusion convolutional recurrent neural networks, INFOCOM 2019](https://ieeexplore.ieee.org/document/8845132).\n\n## Third-party re-implementations\nThe Pytorch implementaion by [chnsh@](https://github.com/chnsh/) is available at [DCRNN-Pytorch](https://github.com/chnsh/DCRNN_PyTorch).\n\n\n## Citation\n\nIf you find this repository, e.g., the code and the datasets, useful in your research, please cite the following paper:\n```\n@inproceedings{li2018dcrnn_traffic,\n  title={Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting},\n  author={Li, Yaguang and Yu, Rose and Shahabi, Cyrus and Liu, Yan},\n  booktitle={International Conference on Learning Representations (ICLR '18)},\n  year={2018}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyaguang%2FDCRNN","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliyaguang%2FDCRNN","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyaguang%2FDCRNN/lists"}