Home

Awesome

Spectral Temporal Graph Neural Network for Multivariate Time-series Forecasting

This repository is the official implementation of Spectral Temporal Graph Neural Network for Multivariate Time-series Forecasting.

Requirements

Recommended version of OS & Python:

To 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:

python3.7 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt

Datasets

PEMS03, PEMS04, PEMS07, PEMS08, METR-LA, PEMS-BAY, Solar, Electricity, ECG5000, COVID-19

We 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'.

The 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.

Since 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) 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.

Training and Evaluation

The training procedure and evaluation procedure are all included in the main.py. To train and evaluate on some dataset, run the following command:

python main.py --train True --evaluate True --dataset <name of csv file> --output_dir <path to output directory> --n_route <number of nodes> --window_size <length of sliding window> --horizon <predict horizon> --norm_method z_score --train_length 7 --validate_length 2 --test_length 1

The detailed descriptions about the parameters are as following:

Parameter nameDescription of parameter
trainwhether to enable training, default True
evaluatewhether to enable evaluation, default True
datasetfile name of input csv
window_sizelength of sliding window, default 12
horizonpredict horizon, default 3
train_lengthlength of training data, default 7
validate_lengthlength of validation data, default 2
test_lengthlength of testing data, default 1
epochepoch size during training
lrlearning rate
multi_layerhyper parameter of STemGNN which controls the parameter number of hidden layers, default 5
devicedevice that the code works on, 'cpu' or 'cuda:x'
validate_freqfrequency of validation
batch_sizebatch size
norm_methodmethod for normalization, 'z_score' or 'min_max'
early_stopwhether to enable early stop, default False

Table 1 Configurations for all datasets

Datasettrainevaluatenode_cntwindow_sizehorizonnorm_method
METR-LATrueTrue207123z_score
PEMS-BAYTrueTrue325123z_score
PEMS03TrueTrue358123z_score
PEMS04TrueTrue307123z_score
PEMS07TrueTrue228123z_score
PEMS08TrueTrue170123z_score
COVID-19TrueTrue252828z_score

Results

Our model achieves the following performance on the 10 datasets:

Table 2 (predict horizon: 3 steps)

DatasetMAERMSEMAPE(%)
METR-LA2.565.066.46
PEMS-BAY1.232.482.63
PEMS0314.3221.6416.24
PEMS0420.2432.1510.03
PEMS072.144.015.01
PEMS0815.8324.939.26

Table 3 (predict horizon: 28 steps)

DatasetMAERMSEMAPE
COVID-19662.241023.1919.3