ts-exogenous-forecast
Time SeriesTime-Series-Library
Description
Exogenous Variable Forecasting: Custom Model Design
Objective
Design and implement a custom deep learning model for time series forecasting with exogenous (external) variables. Uses features=MS: all variables as input, predict only the target (last dimension). Your code goes in the Model class in models/Custom.py. Three reference implementations (DLinear, PatchTST, iTransformer) are provided as read-only.
Evaluation
Trained and evaluated on three datasets with MS features:
- ETTh1 (7 → 1, hourly electricity data)
- Weather (21 → 1, weather observations)
- ECL (321 → 1, electricity consumption)
All use seq_len=96, pred_len=96. Metrics: MSE and MAE on the target variable (lower is better). The framework automatically extracts outputs[:, :, -1:].
Code
Custom.py
EditableRead-only
1import torch2import torch.nn as nn345class Model(nn.Module):6"""7Custom model for exogenous variable forecasting (features=MS).89Forward signature: forward(x_enc, x_mark_enc, x_dec, x_mark_dec, mask=None)10- x_enc: [batch, seq_len, enc_in] — all input variables11- 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/PatchTST.pyTime-Series-Library/models/iTransformer.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 | mse ETTh1 ↓ | mae ETTh1 ↓ | mse Weather ↓ | mae Weather ↓ | mse ECL ↓ | mae ECL ↓ |
|---|---|---|---|---|---|---|---|
| dlinear | baseline | 0.064 | 0.188 | 0.006 | 0.063 | 0.387 | 0.451 |
| itransformer | baseline | 0.059 | 0.187 | 0.001 | 0.027 | 0.301 | 0.405 |
| patchtst | baseline | 0.058 | 0.183 | 0.002 | 0.029 | 0.318 | 0.395 |
| timexer | baseline | 0.057 | 0.181 | 0.001 | 0.027 | 0.266 | 0.368 |
| timexer | baseline | 0.057 | 0.183 | 0.001 | 0.027 | 0.262 | 0.365 |
| anthropic/claude-opus-4.6 | vanilla | 0.056 | 0.179 | 0.001 | 0.026 | 0.418 | 0.478 |
| deepseek-reasoner | vanilla | 0.064 | 0.192 | 0.001 | 0.028 | 0.320 | 0.416 |
| google/gemini-3.1-pro-preview | vanilla | 0.062 | 0.189 | 0.001 | 0.027 | 0.339 | 0.441 |
| openai/gpt-5.4-pro | vanilla | 0.056 | 0.179 | 0.001 | 0.025 | 0.310 | 0.398 |
| anthropic/claude-opus-4.6 | agent | 0.065 | 0.188 | 0.006 | 0.063 | 0.388 | 0.457 |
| deepseek-reasoner | agent | 0.068 | 0.200 | 0.001 | 0.027 | 0.301 | 0.406 |
| google/gemini-3.1-pro-preview | agent | 0.057 | 0.182 | 0.001 | 0.027 | 0.279 | 0.384 |
| openai/gpt-5.4-pro | agent | 0.056 | 0.179 | 0.001 | 0.026 | 0.260 | 0.364 |
| qwen/qwen3.6-plus:free | agent | 0.058 | 0.183 | 0.001 | 0.028 | 0.497 | 0.535 |