RepositoryPythonCNChina
LMissher

LMissher/PatchSTG

[SIGKDD'2025] Efficient Large-Scale Traffic Forecasting with Transformers: A Spatial Data Management Perspective

88stars
11forks
3issues
4views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: spatial-partitioning

#1 Repository of the month

1
TINIX TRENDING·Topic: traffic-forecasting

#1 Repository of the month

1
TINIX TRENDING·Topic: spatio-temporal-forecasting

#1 Repository of the month

[SIGKDD'25 PatchSTG] Efficient Large-Scale Traffic Forecasting with Transformers: A Spatial Data Management Perspective

PWC Arxiv link


🙋 Please let us know if you find out a mistake or have any suggestions!

🌟 If you find this resource helpful, please consider to star this repository and cite our research:

@article{fang2024efficient,
  title={Efficient Large-Scale Traffic Forecasting with Transformers: A Spatial Data Management Perspective},
  author={Fang, Yuchen and Liang, Yuxuan and Hui, Bo and Shao, Zezhi and Deng, Liwei and Liu, Xu and Jiang, Xinke and Zheng, Kai},
  journal={arXiv preprint arXiv:2412.09972},
  year={2024}
}

Introduction

PatchSTG is an attention-based dynamic spatial modeling method that uses irregular spatial patching for efficient large-scale traffic forecasting. Notably, we show that spatiotemporal graphs can be patched on the spatial dimension, effectively reducing complexity in attention.

  • PatchSTG comprises four components: (1) embedding the input traffic into high-dimensional representations with spatio-temporal properties, (2) segmenting the large-scale input into balanced and non-overlapped patches on the spatial dimension with irregularly distributed points, (3) using depth and breadth attentions on the patched input to capture local and global spatial dependencies efficiently, and (4) projecting representations to the predicted future traffic.

Hyper-parameters

  • tps: temporal patch size
  • tpn: temporal patch number ($tps\times tpn==input_len$)
  • recur: KDTree depth ($recur<\lfloor log_2(nodes)\rfloor$)
  • sps: KDTree leaf size
  • spn: KDTree nodes ($spn=2^{recur}$)
  • factors: $sps\times factors$ is the spatial patch size and $spn/factors$ is the spatial patch number

Requirements

  • torch==1.11.0
  • timm==1.0.12
  • scikit_learn==1.0.2
  • tqdm==4.67.1
  • pandas==1.4.1
  • numpy==1.22.3

Folder Structure

└── code-and-data
    ├── config                 # Including detail configurations
    ├── cpt                    # Storing pre-trained weight files (manually create the folder and download files)
    ├── data                   # Including traffic data (download), adj files (generated), and the meta data
    ├── lib
    │   |──  utils.py          # Codes of preprocessing datasets and calculating metrics
    ├── log                    # Storing log files
    ├── model
    │   |──  models.py         # The core source code of our PatchSTG
    ├── main.py                # This is the main file for training and testing
    └── README.md              # This document

Datasets

You can access the well pre-processed datasets from [Google Drive], then place the downloaded contents under the correspond dataset folder such as ./data/SD.

PreTrained Weights

You can access the pretrained weights from [Google Drive], then place the downloaded contents under the constructed cpt folder ./cpt.

Quick Demos

  1. Download datasets and place them under ./data
  2. We provide pre-trained weights of results in the paper and the detail configurations under the folder ./config. For example, you can test the SD dataset by:
python main.py --config ./config/SD.conf
  1. If you want to train the model yourself, you can use the code at line 262 of the main file.

Further Reading

1, When Spatio-Temporal Meet Wavelets: Disentangled Traffic Forecasting via Efficient Spectral Graph Attention Networks, in ICDE 2023. [GitHub Repo]

Authors: Yuchen Fang, Yanjun Qin, Haiyong Luo, Fang Zhao, Bingbing Xu, Liang Zeng, Chenxing Wang.

@inproceedings{fang2023spatio,
  title={When spatio-temporal meet wavelets: Disentangled traffic forecasting via efficient spectral graph attention networks},
  author={Fang, Yuchen and Qin, Yanjun and Luo, Haiyong and Zhao, Fang and Xu, Bingbing and Zeng, Liang and Wang, Chenxing},
  booktitle={2023 IEEE 39th International Conference on Data Engineering (ICDE)},
  pages={517--529},
  year={2023}
}

Similar Projects

Discover other similar projects and AI models.

Modeltime-series-forecasting
autogluon/chronos-2

Chronos-2 Update Jun 5, 2026: ☁️ Deploy Chronos-2 on AWS with AutoGluon-Cloud. Real-time, serverless, or batch inference in 3 lines of code — pandas DataFrames in, forecasts out. Check out the new deployment guide(https://auto.gluon.ai/cloud/stable/...

♥0
80.6M
Jun 5, 2026
RepositoryPython
kwuking/TimeMixer

[ICLR 2024] Official implementation of "TimeMixer: Decomposable Multiscale Mixing for Time Series Forecasting"

2.0k
Oct 5, 2025
RepositoryPython
wengwenchao123/DDGCRN

[Pattern Recognition] Decomposition Dynamic Graph Conolutional Recurrent Network for Traffic Forecasting

103
Sep 2, 2025
Modeltime-series-forecasting
amazon/chronos-2

Chronos-2 Update Jun 5, 2026: ☁️ Deploy Chronos-2 on AWS with AutoGluon-Cloud. Real-time, serverless, or batch inference in 3 lines of code — pandas DataFrames in, forecasts out. Check out the new deployment guide(https://auto.gluon.ai/cloud/stable/...

♥0
11.1M
Jun 5, 2026
Modeltime-series-forecasting
autogluon/chronos-bolt-small

Chronos-Bolt⚡ (Small) 🚀 Update Feb 14, 2025: Chronos-Bolt models are now available on Amazon SageMaker JumpStart! Check out the tutorial notebook(https://github.com/amazon-science/chronos-forecasting/blob/main/notebooks/deploy-chronos-to-amazon-sag...

♥0
4.9M
Oct 30, 2025
Modeltime-series-forecasting
google/timesfm-3.0-pytorch

TimesFM 3.0 (PyTorch) TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting. This repository contains the official PyTorch weights and configurations for TimesFM...

♥0
324.8k
Sep 2, 2026
Modeltime-series-forecasting
NeoQuasar/Kronos-Tokenizer-base

Kronos: A Foundation Model for the Language of Financial Markets !Paper(https://img.shields.io/badge/Paper-2508.02739-b31b1b.svg)(https://arxiv.org/abs/2508.02739) !Live Demo(https://img.shields.io/badge/%F0%9F%9A%80-LiveDemo-brightgreen)(https://sh...

♥0
3.9M
Sep 9, 2025
Modeltime-series-forecasting
google/timesfm-1.0-200m

TimesFM TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting. Resources and Technical Documentation: Paper: A decoder-only foundation model for time-series forec...

♥0
212
May 17, 2024
Modeltime-series-forecasting
google/timesfm-2.5-200m-pytorch

TimesFM TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting. Updates October 2, 2025: We changed the structure of the model to fuse QKV matrices into one for sp...

♥0
1.9M
Oct 2, 2025