autogluon/chronos_datasets
Viewer • Updated • 10.4M • 43.1k • 73
State-of-the-art monthly seasonal time series forecasting model, fine-tuned on the M4 Monthly competition dataset (48,000 time series).
Based on PatchTST (ICLR 2023) — a patch-based Transformer for time series that:
| Parameter | Value |
|---|---|
| Dataset | M4 Monthly (48,000 series, 6 categories) |
| Context Length | 48 months (4 years) |
| Prediction Length | 18 months |
| Patch Length | 6 months |
| d_model | 128 |
| Attention Heads | 8 |
| Transformer Layers | 3 |
| Epochs | 2000 steps |
| Batch Size | 128 |
| Learning Rate | 0.001 (cosine schedule) |
| Optimizer | AdamW (weight_decay=0.01) |
| Model | MASE (mean) | sMAPE (mean) |
|---|---|---|
| PatchTST (ours) | 1.0243 | 14.04 |
| Chronos-Bolt (zero-shot) | 0.9202 | 13.72 |
| Seasonal Naive | 1.2453 | 16.36 |
| Category | MASE | sMAPE | # Series |
|---|---|---|---|
| Macro | 1.0693 | 14.79 | 407 |
| Micro | 0.9918 | 17.13 | 472 |
| Finance | 1.0292 | 14.86 | 485 |
| Industry | 1.0650 | 13.75 | 410 |
| Demographic | 0.9344 | 4.33 | 214 |
| Other | 0.7960 | 17.58 | 12 |
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)