{"id":13958499,"url":"https://github.com/microsoft/StemGNN","last_synced_at":"2025-07-21T00:31:13.457Z","repository":{"id":40956467,"uuid":"269320915","full_name":"microsoft/StemGNN","owner":"microsoft","description":"Spectral Temporal Graph Neural Network (StemGNN in short) for Multivariate Time-series Forecasting","archived":false,"fork":false,"pushed_at":"2024-05-31T14:51:50.000Z","size":14896,"stargazers_count":558,"open_issues_count":27,"forks_count":121,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-19T05:49:40.880Z","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/microsoft.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-04T09:49:10.000Z","updated_at":"2025-07-18T15:51:40.000Z","dependencies_parsed_at":"2024-11-28T02:32:19.514Z","dependency_job_id":"4ba32830-6ef4-4a26-bd0c-7b2a645d6d6e","html_url":"https://github.com/microsoft/StemGNN","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/microsoft/StemGNN","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FStemGNN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FStemGNN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FStemGNN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FStemGNN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/StemGNN/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FStemGNN/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266221257,"owners_count":23894965,"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-08-08T13:01:40.278Z","updated_at":"2025-07-21T00:31:08.447Z","avatar_url":"https://github.com/microsoft.png","language":"Python","funding_links":[],"categories":["时间序列"],"sub_categories":["网络服务_其他"],"readme":"# Spectral Temporal Graph Neural Network for Multivariate Time-series Forecasting\n\nThis repository is the official implementation of Spectral Temporal Graph Neural Network for\nMultivariate Time-series Forecasting.\n\n## Requirements\n\nRecommended version of OS \u0026 Python:\n\n* **OS**: Ubuntu 18.04.2 LTS\n* **Python**: python3.7 ([instructions to install python3.7](https://linuxize.com/post/how-to-install-python-3-7-on-ubuntu-18-04/)).\n\nTo install python dependencies, virtualenv is recommended, `sudo apt install python3.7-venv` to install virtualenv for python3.7. All the python dependencies are verified for `pip==20.1.1` and `setuptools==41.2.0`. Run the following commands to create a venv and install python dependencies:\n\n```setup\npython3.7 -m venv venv\nsource venv/bin/activate\npip install --upgrade pip\npip install -r requirements.txt\n```\n\n## Datasets\n\n[PEMS03](http://pems.dot.ca.gov/?dnode=Clearinghouse\u0026type=station_5min\u0026district_id=3\u0026submit=Submit),\n[PEMS04](http://pems.dot.ca.gov/?dnode=Clearinghouse\u0026type=station_5min\u0026district_id=4\u0026submit=Submit),\n[PEMS07](http://pems.dot.ca.gov/?dnode=Clearinghouse\u0026type=station_5min\u0026district_id=7\u0026submit=Submit),\n[PEMS08](http://pems.dot.ca.gov/?dnode=Clearinghouse\u0026type=station_5min\u0026district_id=8\u0026submit=Submit),\n[METR-LA](https://github.com/liyaguang/DCRNN),\n[PEMS-BAY](https://github.com/liyaguang/DCRNN),\n[Solar](https://www.nrel.gov/grid/solar-power-data.html),\n[Electricity](https://archive.ics.uci.edu/ml/datasets/ElectricityLoadDiagrams20112014),\n[ECG5000](http://www.timeseriesclassification.com/description.php?Dataset=ECG5000),\n[COVID-19](https://github.com/CSSEGISandData/COVID-19/tree/master)\n\nWe can get the raw data through the links above. We evaluate the performance of traffic flow forecasting on PEMS03, PEMS07, PEMS08 and traffic speed forecasting on PEMS04, PEMS-BAY and METR-LA. So we use the traffic flow table of PEMS03, PEMS07, PEMS08 and the traffic speed table of PEMS04, PEMS-BAY and METR-LA as our datasets. We download the solar power data of Alabama (Eastern States) and merge the 5-minute csv files (totally 137 time series) as our Solar dataset. We delete the header and index of Electricity file downloaded from the link above as our Electricity dataset. For COVID-19 dataset, the raw data is under the folder `csse_covid_19_data/csse_covid_19_time_series/` of the above github link. We use `time_series_covid19_confirmed_global.csv` to calculate the daily number of newly confirmed infected people from 1/22/2020 to 5/10/2020. The 25 countries we take into consideration are 'US','Canada','Mexico','Russia','UK','Italy','Germany','France','Belarus ','Brazil','Peru','Ecuador','Chile','India','Turkey','Saudi Arabia','Pakistan','Iran','Singapore','Qatar','Bangladesh','Arab','China','Japan','Korea'.\n\nThe input csv file should contain **no header** and its **shape should be `T*N`**, where `T` denotes total number of timestamps, `N` denotes number of nodes.\n\nSince complex data cleansing is needed on the above datasets provided in the urls before fed into the StemGNN model, we provide a cleaned version of ECG5000 ([./dataset/ECG_data.csv](./dataset/ECG_data.csv)) for reproduction convenience. The ECG_data.csv is in shape of `5000*140`, where `5000` denotes number of timestamps and `140` denotes total number of nodes. Run command `python main.py` to trigger training and evaluation on ECG_data.csv.\n\n## Training and Evaluation\n\nThe training procedure and evaluation procedure are all included in the `main.py`. To train and evaluate on some dataset, run the following command:\n\n```train \u0026 evaluate\npython main.py --train True --evaluate True --dataset \u003cname of csv file\u003e --output_dir \u003cpath to output directory\u003e --n_route \u003cnumber of nodes\u003e --window_size \u003clength of sliding window\u003e --horizon \u003cpredict horizon\u003e --norm_method z_score --train_length 7 --validate_length 2 --test_length 1\n```\n\nThe detailed descriptions about the parameters are as following:\n\n| Parameter name | Description of parameter |\n| --- | --- |\n| train | whether to enable training, default True |\n| evaluate | whether to enable evaluation, default True |\n| dataset | file name of input csv |\n| window_size | length of sliding window, default 12 |\n| horizon | predict horizon, default 3 |\n| train_length | length of training data, default 7 |\n| validate_length | length of validation data, default 2 |\n| test_length | length of testing data, default 1 |\n| epoch | epoch size during training |\n| lr | learning rate |\n| multi_layer | hyper parameter of STemGNN which controls the parameter number of hidden layers, default 5 |\n| device | device that the code works on, 'cpu' or 'cuda:x' | \n| validate_freq | frequency of validation |\n| batch_size | batch size |\n| norm_method | method for normalization, 'z_score' or 'min_max' |\n| early_stop | whether to enable early stop, default False |\n\n\n**Table 1** Configurations for all datasets\n| Dataset | train | evaluate | node_cnt | window_size | horizon | norm_method |\n| -----   | ---- | ---- |---- |---- |---- | --- |\n| METR-LA | True | True | 207 | 12 | 3 | z_score |\n| PEMS-BAY | True | True |  325 | 12 | 3 | z_score |\n| PEMS03 | True | True |  358 | 12 | 3 | z_score |\n| PEMS04 | True | True |  307 | 12 | 3 | z_score |\n| PEMS07 | True | True | 228 | 12 | 3 | z_score |\n| PEMS08 | True | True |  170 | 12 | 3 | z_score |\n| COVID-19| True | True | 25 | 28 | 28 | z_score |\n\n## Results\n\nOur model achieves the following performance on the 10 datasets:\n\n**Table 2** (predict horizon: 3 steps)\n\n| Dataset | MAE  | RMSE | MAPE(%) |\n| -----   | ---- | ---- | ---- |\n| METR-LA | 2.56 | 5.06 | 6.46 |\n| PEMS-BAY | 1.23 | 2.48 | 2.63 |\n| PEMS03 | 14.32 | 21.64 | 16.24 |\n| PEMS04 | 20.24 | 32.15 | 10.03 |\n| PEMS07 | 2.14 | 4.01 | 5.01 |\n| PEMS08 | 15.83 | 24.93 | 9.26 |\n\n**Table 3** (predict horizon: 28 steps)\n\n| Dataset | MAE  | RMSE | MAPE |\n| -----   | ---- | ---- | ---- |\n| COVID-19 | 662.24 | 1023.19| 19.3|\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2FStemGNN","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2FStemGNN","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2FStemGNN/lists"}