microsoft / ProbTS

ProbTS is a benchmarking toolkit for time series forecasting.
MIT License
88 stars 10 forks source link

ProbTS: Benchmarking Point and Distributional Forecasting across Diverse Prediction Horizons


[ Paper | Benchmarking | Documentation ]

A wide range of industrial applications desire precise point and distributional forecasting for diverse prediction horizons. ProbTS serves as a benchmarking tool to aid in understanding how advanced time-series models fulfill these essential forecasting needs. It also sheds light on their advantages and disadvantages in addressing different challenges and unveil the possibilities for future research.

To achieve these objectives, ProbTS provides a unified pipeline that implements cutting-edge models from different research threads, including:

Specifically, ProbTS emphasizes the differences in their primary methodological designs, including:

Available Models 🧩

ProbTS includes both classical time-series models, specializing in long-term point forecasting or short-term distributional forecasting, and recent time-series foundation models that offer zero-shot and arbitrary-horizon forecasting capabilities for new time series.

Classical Time-series Models

Model Original Eval. Horizon Estimation Decoding Scheme Class Path
Linear - Point Auto / Non-auto probts.model.forecaster.point_forecaster.LinearForecaster
GRU - Point Auto / Non-auto probts.model.forecaster.point_forecaster.GRUForecaster
Transformer - Point Auto / Non-auto probts.model.forecaster.point_forecaster.TransformerForecaster
Autoformer Long-trem Point Non-auto probts.model.forecaster.point_forecaster.Autoformer
N-HiTS Long-trem Point Non-auto probts.model.forecaster.point_forecaster.NHiTS
NLinear Long-trem Point Non-auto probts.model.forecaster.point_forecaster.NLinear
DLinear Long-trem Point Non-auto probts.model.forecaster.point_forecaster.DLinear
TimesNet Short- / Long-term Point Non-auto probts.model.forecaster.point_forecaster.TimesNet
PatchTST Long-trem Point Non-auto probts.model.forecaster.point_forecaster.PatchTST
iTransformer Long-trem Point Non-auto probts.model.forecaster.point_forecaster.iTransformer
GRU NVP Short-term Probabilistic Auto probts.model.forecaster.prob_forecaster.GRU_NVP
GRU MAF Short-term Probabilistic Auto probts.model.forecaster.prob_forecaster.GRU_MAF
Trans MAF Short-term Probabilistic Auto probts.model.forecaster.prob_forecaster.Trans_MAF
TimeGrad Short-term Probabilistic Auto probts.model.forecaster.prob_forecaster.TimeGrad
CSDI Short-term Probabilistic Non-auto probts.model.forecaster.prob_forecaster.CSDI
TSDiff Short-term Probabilistic Non-auto probts.model.forecaster.prob_forecaster.TSDiffCond

Fundation Models

Model Any Horizon Estimation Decoding Scheme Class Path
Lag-Llama Probabilistic Auto probts.model.forecaster.prob_forecaster.LagLlama
ForecastPFN Point Non-auto probts.model.forecaster.point_forecaster.ForecastPFN
TimesFM Point Auto probts.model.forecaster.point_forecaster.TimesFM
TTM Point Non-auto probts.model.forecaster.point_forecaster.TinyTimeMixer
Timer Point Auto probts.model.forecaster.point_forecaster.Timer
MOIRAI Probabilistic Non-auto probts.model.forecaster.prob_forecaster.Moirai
UniTS Point Non-auto probts.model.forecaster.point_forecaster.UniTS
Chronos Probabilistic Auto probts.model.forecaster.prob_forecaster.Chronos

Stay tuned for more models to be added in the future.

Setup :wrench:

Environment

ProbTS is developed with Python 3.10 and relies on PyTorch Lightning. To set up the environment:

# Create a new conda environment
conda create -n probts python=3.10
conda activate probts

# Install required packages
pip install .
pip uninstall -y probts # recommended to uninstall the root package (optional)

[Optional] For time-series foundation models, you need to install basic packages and additional dependencies:

# Create a new conda environment
conda create -n probts_fm python=3.10
conda activate probts_fm

# Git submodule
git submodule update --init --recursive

# Install additional packages for foundation models
pip install ".[tsfm]"
pip uninstall -y probts # recommended to uninstall the root package (optional)

# For MOIRAI, we fix the version of the package for better performance
cd submodules/uni2ts
git reset --hard fce6a6f57bc3bc1a57c7feb3abc6c7eb2f264301
Optional for TSFMs reproducibility ```bash # For TimesFM, fix the version for reproducibility (optional) cd submodules/timesfm git reset --hard 5c7b905 # For Lag-Llama, fix the version for reproducibility (optional) cd submodules/lag_llama git reset --hard 4ad82d9 # For TinyTimeMixer, fix the version for reproducibility (optional) cd submodules/tsfm git reset --hard bb125c14a05e4231636d6b64f8951d5fe96da1dc ```

Datasets

Checkpoints for Foundation Models

Download the checkpoints with the following command (details can be found here):

bash scripts/prepare_tsfm_checkpoints.sh # By downloading, you agree to the original licenses

Quick Start :rocket:

Specify --config with a specific configuration file to reproduce results of point or probabilistic models on commonly used long- and short-term forecasting datasets. Configuration files are included in the config folder.

To run models:

bash run.sh

Experimental results reproduction:

Short-term Forecasting Configuration

For short-term forecasting scenarios, datasets and corresponding context_length and prediction_length are automatically obtained from GluonTS. Use the following command:

python run.py --config config/path/to/model.yaml \
                --data.data_manager.init_args.path /path/to/datasets/ \
                --trainer.default_root_dir /path/to/log_dir/ \
                --data.data_manager.init_args.dataset {DATASET_NAME}

See full DATASET_NAME list:

from gluonts.dataset.repository import dataset_names
print(dataset_names)

Long-term Forecasting Configuration

For long-term forecasting scenarios, context_length and prediction_length must be explicitly assigned:

python run.py --config config/path/to/model.yaml \
                --data.data_manager.init_args.path /path/to/datasets/ \
                --trainer.default_root_dir /path/to/log_dir/ \
                --data.data_manager.init_args.dataset {DATASET_NAME} \
                --data.data_manager.init_args.context_length {CTX_LEN} \
                --data.data_manager.init_args.prediction_length {PRED_LEN} 

DATASET_NAME options:

['etth1', 'etth2','ettm1','ettm2','traffic_ltsf', 'electricity_ltsf', 'exchange_ltsf', 'illness_ltsf', 'weather_ltsf', 'caiso', 'nordpool']

Benchmarking :balance_scale:

By utilizing ProbTS, we conduct a systematic comparison between studies that focus on point forecasting and those aimed at distributional estimation, employing various forecasting horizons and evaluation metrics. For more details

Documentation :open_book:

For detailed information on configuration parameters and model customization, please refer to the documentation.

Key Configuration Parameters

Config Name Type Description
trainer.max_epochs integer Maximum number of training epochs.
model.forecaster.class_path string Forecaster module path (e.g., probts.model.forecaster.point_forecaster.PatchTST).
model.forecaster.init_args.{ARG} - Model-specific hyperparameters.
model.num_samples integer Number of samples per distribution during evaluation.
model.learning_rate float Learning rate.
data.data_manager.init_args.dataset string Dataset for training and evaluation.
data.data_manager.init_args.path string Path to the dataset folder.
data.data_manager.init_args.scaler string Scaler type: identity, standard (z-score normalization), or temporal (scale based on average temporal absolute value).
data.data_manager.init_args.context_length integer Length of observation window (required for long-term forecasting).
data.data_manager.init_args.prediction_length integer Forecasting horizon length (required for long-term forecasting).
data.data_manager.init_args.var_specific_norm boolean If conduct per-variate normalization or not.
data.batch_size integer Batch size.

Acknowledgement 🌟

Special thanks to the following repositories for their open-sourced code bases and datasets.

Tools/Packages

Official Implementations

Classical Time-series Models

Time-series Foundation Models

Citing ProbTS 🌟

If you have used ProbTS for research or production, please cite it as follows.

@article{zhang2023probts,
  title={{ProbTS}: Benchmarking Point and Distributional Forecasting across Diverse Prediction Horizons},
  author={Zhang, Jiawen and Wen, Xumeng and Zhang, Zhenwei and Zheng, Shun and Li, Jia and Bian, Jiang},
  journal={arXiv preprint arXiv:2310.07446},
  year={2023}
}