ts-imputation
Time SeriesTime-Series-Library
Description
Time Series Imputation: Custom Model Design
Objective
Design and implement a custom deep learning model for time series missing value imputation. 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 multivariate datasets with 25% random masking:
- ETTh1 (7 variables)
- Weather (21 variables)
- ECL (321 variables)
All use seq_len=96. Metrics: MSE and MAE on masked regions only (lower is better).
Code
Custom.py
EditableRead-only
1import torch2import torch.nn as nn345class Model(nn.Module):6"""7Custom model for time series imputation.89Forward signature: forward(x_enc, x_mark_enc, x_dec, x_mark_dec, mask=None)10- x_enc: [batch, seq_len, enc_in] — input with masked values set to 011- x_mark_enc: [batch, seq_len, time_features] — time feature encoding12- x_dec: not used for imputation (None)13- x_mark_dec: not used for imputation (None)14- mask: [batch, seq_len, enc_in] — binary mask (1=observed, 0=masked)15
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 | mse ETTh1 ↓ | mae ETTh1 ↓ | mse Weather ↓ | mae Weather ↓ | mse ECL ↓ | mae ECL ↓ |
|---|---|---|---|---|---|---|---|
| dlinear | baseline | 0.150 | 0.269 | 0.050 | 0.114 | 0.113 | 0.243 |
| patchtst | baseline | 0.104 | 0.216 | 0.031 | 0.052 | 0.062 | 0.169 |
| patchtst | baseline | 0.106 | 0.217 | 0.031 | 0.053 | 0.062 | 0.169 |
| timesnet | baseline | 0.080 | 0.191 | 0.029 | 0.055 | 0.091 | 0.208 |
| anthropic/claude-opus-4.6 | vanilla | 0.037 | 0.131 | 0.051 | 0.092 | 0.078 | 0.192 |
| deepseek-reasoner | vanilla | 0.039 | 0.130 | 0.029 | 0.055 | 0.076 | 0.190 |
| google/gemini-3.1-pro-preview | vanilla | 0.064 | 0.171 | 0.109 | 0.169 | 0.795 | 0.743 |
| openai/gpt-5.4-pro | vanilla | 0.042 | 0.138 | 0.026 | 0.038 | 0.055 | 0.157 |
| qwen/qwen3.6-plus:free | vanilla | 0.188 | 0.281 | 0.054 | 0.080 | 0.118 | 0.239 |
| anthropic/claude-opus-4.6 | agent | 0.037 | 0.129 | 0.031 | 0.058 | 0.077 | 0.192 |
| deepseek-reasoner | agent | - | - | - | - | - | - |
| deepseek-reasoner | agent | 0.039 | 0.130 | 0.029 | 0.055 | 0.076 | 0.190 |
| google/gemini-3.1-pro-preview | agent | 0.084 | 0.193 | 0.043 | 0.068 | 0.050 | 0.148 |
| openai/gpt-5.4-pro | agent | 0.044 | 0.141 | 0.025 | 0.036 | 0.050 | 0.150 |
| qwen/qwen3.6-plus:free | agent | 0.188 | 0.281 | 0.054 | 0.080 | 0.118 | 0.239 |