PatchTST Monthly Seasonal Forecast Model
State-of-the-art monthly seasonal time series forecasting model, fine-tuned on the M4 Monthly competition dataset (48,000 time series).
Architecture
Based on PatchTST (ICLR 2023) — a patch-based Transformer for time series that:
- Tokenizes time series into 6-month patches to capture semi-annual seasonal patterns
- Uses sinusoidal positional encoding for temporal awareness
- Applies standard normalization (RevIN) for scale-invariant forecasting
- Achieves strong performance with only 603,538 parameters
Training Details
Evaluation Results (M4 Monthly Test Set, 18-month horizon)
Per-Category Results
Usage
from transformers import PatchTSTForPrediction
import torch
import numpy as np
model = PatchTSTForPrediction.from_pretrained("stevevaius/patchtst-monthly-seasonal")
model.eval()
# Input: monthly time series with at least 48 months of history
# Shape: [batch_size, context_length, 1] (univariate)
monthly_values = np.array([...]) # your monthly data
context = torch.tensor(monthly_values[-48:], dtype=torch.float32).unsqueeze(0).unsqueeze(-1)
with torch.no_grad():
output = model(past_values=context)
forecast = output.prediction_outputs.squeeze().numpy()
# forecast shape: [18] — next 18 months
print("Forecast:", forecast)
References