ts-short-term-forecast
Time SeriesTime-Series-Library
Description
Short-Term Time Series Forecasting: Custom Model Design
Objective
Design and implement a custom deep learning model for univariate short-term time series forecasting on the M4 dataset. Your code goes in the Model class in models/Custom.py. Three reference implementations (DLinear, TimesNet, PatchTST) are provided as read-only.
Evaluation
Trained and evaluated on three M4 seasonal patterns:
- Monthly (pred_len=18, seq_len=104)
- Quarterly (pred_len=8, seq_len=52)
- Yearly (pred_len=6, seq_len=42)
All use enc_in=1, features=M, loss=SMAPE. Metric: SMAPE (lower is better).
Code
Custom.py
EditableRead-only
1import torch2import torch.nn as nn345class Model(nn.Module):6"""7Custom model for short-term time series forecasting (M4 dataset).89Forward signature: forward(x_enc, x_mark_enc, x_dec, x_mark_dec, mask=None)10- x_enc: [batch, seq_len, enc_in] — input time series (enc_in=1 for M4)11- x_mark_enc: [batch, seq_len, time_features] — time feature encoding12- x_dec: [batch, label_len+pred_len, dec_in] — decoder input13- x_mark_dec: [batch, label_len+pred_len, time_features] — decoder time features1415Must return: [batch, pred_len, c_out] for forecasting
Additional context files (read-only):
Time-Series-Library/models/DLinear.pyTime-Series-Library/models/TimesNet.pyTime-Series-Library/models/PatchTST.pyTime-Series-Library/layers/AutoCorrelation.pyTime-Series-Library/layers/Autoformer_EncDec.pyTime-Series-Library/layers/Conv_Blocks.pyTime-Series-Library/layers/Crossformer_EncDec.pyTime-Series-Library/layers/Embed.pyTime-Series-Library/layers/FourierCorrelation.pyTime-Series-Library/layers/SelfAttention_Family.pyTime-Series-Library/layers/StandardNorm.pyTime-Series-Library/layers/Transformer_EncDec.py
Results
| Model | Type | smape m4 monthly ↓ | mape m4 monthly ↓ | smape m4 quarterly ↓ | mape m4 quarterly ↓ | smape m4 yearly ↓ | mape m4 yearly ↓ |
|---|---|---|---|---|---|---|---|
| dlinear | baseline | 13.395 | 0.163 | 10.501 | 0.122 | 14.358 | 0.168 |
| patchtst | baseline | 14.088 | 0.169 | 10.844 | 0.132 | 13.561 | 0.169 |
| patchtst | baseline | 12.968 | 0.154 | 10.219 | 0.118 | 13.679 | 0.167 |
| timemixer | baseline | 12.802 | 0.150 | 10.209 | 0.117 | 13.379 | 0.163 |
| timesnet | baseline | 12.803 | 0.149 | 10.089 | 0.114 | 13.442 | 0.164 |
| anthropic/claude-opus-4.6 | vanilla | 12.917 | 0.154 | 10.324 | 0.120 | 13.798 | 0.165 |
| deepseek-reasoner | vanilla | 13.413 | 0.163 | 10.766 | 0.125 | 13.652 | 0.164 |
| google/gemini-3.1-pro-preview | vanilla | 12.662 | 0.148 | 10.084 | 0.116 | 13.575 | 0.165 |
| openai/gpt-5.4-pro | vanilla | 12.892 | 0.153 | 10.208 | 0.118 | 13.552 | 0.163 |
| qwen/qwen3.6-plus:free | vanilla | 13.151 | 0.156 | 10.505 | 0.122 | 13.548 | 0.167 |
| anthropic/claude-opus-4.6 | agent | 12.917 | 0.154 | 10.324 | 0.120 | 13.798 | 0.165 |
| deepseek-reasoner | agent | - | - | - | - | - | - |
| deepseek-reasoner | agent | 13.413 | 0.163 | 10.766 | 0.125 | 13.652 | 0.164 |
| google/gemini-3.1-pro-preview | agent | 12.588 | 0.147 | 10.119 | 0.116 | 13.509 | 0.163 |
| gpt-5.4-pro | agent | 13.032 | 0.157 | 10.508 | 0.122 | 13.584 | 0.166 |
| openai/gpt-5.4-pro | agent | 12.892 | 0.153 | 10.208 | 0.118 | 13.552 | 0.163 |
| qwen/qwen3.6-plus:free | agent | 13.204 | 0.160 | 10.601 | 0.124 | 13.855 | 0.168 |