Home

Awesome

LaST: Learning Latent Seasonal-Trend Representations for Time Series Forecasting

In this repository, we provide the original PyTorch implementation of LaST framework.

Dataset

We conducted extensive experiments on seven real-world benchmark datasets from four covering the categories of mainstream time series forecasting applications.

Please download from the following buttons and place them into datasets folder.

Usage

Requirements

The code was tested with python 3.8, pytorch 1.8.1, cudatookkit 10.2, and cudnn 7.6.5. Install the dependencies via Anaconda:

# create virtual environment
conda create --name LaST python=3.8

# activate environment
conda activate LaST

# install pytorch & cudatoolkit
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch-lts

# install other requirements
conda install numpy pandas

Run code

To train and evaluate LaST framework on a dataset, run the following command:

python run.py --data <dataset_name>  --features <forecasting_mode>  --seq_len <input_length>  --pred_len <pred_length>  --latent_size <latent_size>  --batch_size <batch_size>  --patience <patience>  --seed <random_seed>

The detailed descriptions about the arguments are as following:

Parameter nameDescription
dataset_nameThe dataset name can be selected from ["ETTh1", "ETTh2", "ETTm1", "ETTm2", "Exchange_rate", "Electricity", "Weather"]
forecasting_modeA value in ["S", "M"]. "S" denotes univariate forecasting while "M" denotes multivariate forecasting.
input_lengthThe input (historical) sequence length, default is 201.
pred_lengthThe output (forecasting) sequence length.
latent_sizeThe dimension of latent representations, default is 128.
batch_sizeBatch size, default is 32.
patienceThe steps of early stop strategy in training.
random_seedThe random seed.

Directory Structure

The code directory structure is shown as follows:

LaST
├── datasets  # seven datasets files
│   ├── ETTh1.csv
│   ├── ETTh2.csv
│   ├── ETTm1.csv
│   ├── ETTm2.csv
│   ├── electricity.csv
│   ├── exchange_rate.csv
│   └── weather.csv
├── expriments  # training, validation, and test code of LaST
│   ├── exp_basic.py
│   └── exp_LaST.py
├── models  # code of LaST and its dependencies
│   ├── LaST.py  # LaST main code
│   └── utils.py  # modules for LaST including autocorrelation, cort, etc.
├── utlis
│   ├── data_loader.py  # data loading and preprocessing code
│   ├── metrics.py  # metrics for evaluation
│   ├── timefeatures.py  # extract time-related features
│   └── tools.py  # tools for training, such as early stopping and learning rate controls 
├── LICENSE  # code license
├── run.py  # entry for model training, validation, and test 
└── README.md  # This file

Citation

Please cite our paper if it's helpful to you in your research.

@inproceedings{wang2022latent,
    title = "Learning Latent Seasonal-Trend Representations for Time Series Forecasting",
    author = "Wang, Zhiyuan  and  Xu, Xovee  and  Zhang, Weifeng  and  Trajcevski, Goce  and  Zhong, Ting  and  Zhou, Fan",
    booktitle = "Advances in Neural Information Processing Systems",
    year = "2022"
}