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 torch
2import torch.nn as nn
3
4
5class Model(nn.Module):
6 """
7 Custom model for exogenous variable forecasting (features=MS).
8
9 Forward signature: forward(x_enc, x_mark_enc, x_dec, x_mark_dec, mask=None)
10 - x_enc: [batch, seq_len, enc_in] — all input variables
11 - x_mark_enc: [batch, seq_len, time_features] — time feature encoding
12 - x_dec: [batch, label_len+pred_len, dec_in] — decoder input
13 - x_mark_dec: [batch, label_len+pred_len, time_features] — decoder time features
14
15 Must return: [batch, pred_len, c_out] for forecasting

Additional context files (read-only):

  • Time-Series-Library/models/DLinear.py
  • Time-Series-Library/models/PatchTST.py
  • Time-Series-Library/models/iTransformer.py
  • Time-Series-Library/layers/AutoCorrelation.py
  • Time-Series-Library/layers/Autoformer_EncDec.py
  • Time-Series-Library/layers/Conv_Blocks.py
  • Time-Series-Library/layers/Crossformer_EncDec.py
  • Time-Series-Library/layers/Embed.py
  • Time-Series-Library/layers/FourierCorrelation.py
  • Time-Series-Library/layers/SelfAttention_Family.py
  • Time-Series-Library/layers/StandardNorm.py
  • Time-Series-Library/layers/Transformer_EncDec.py

Results

ModelTypemse ETTh1 mae ETTh1 mse Weather mae Weather mse ECL mae ECL
dlinearbaseline0.0640.1880.0060.0630.3870.451
itransformerbaseline0.0590.1870.0010.0270.3010.405
patchtstbaseline0.0580.1830.0020.0290.3180.395
timexerbaseline0.0570.1810.0010.0270.2660.368
timexerbaseline0.0570.1830.0010.0270.2620.365
anthropic/claude-opus-4.6vanilla0.0560.1790.0010.0260.4180.478
deepseek-reasonervanilla0.0640.1920.0010.0280.3200.416
google/gemini-3.1-pro-previewvanilla0.0620.1890.0010.0270.3390.441
openai/gpt-5.4-provanilla0.0560.1790.0010.0250.3100.398
anthropic/claude-opus-4.6agent0.0650.1880.0060.0630.3880.457
deepseek-reasoneragent0.0680.2000.0010.0270.3010.406
google/gemini-3.1-pro-previewagent0.0570.1820.0010.0270.2790.384
openai/gpt-5.4-proagent0.0560.1790.0010.0260.2600.364
qwen/qwen3.6-plus:freeagent0.0580.1830.0010.0280.4970.535

Agent Conversations