Amar Merabti · notebook FR
← Back to the notebook

Exp. 04 · 2025 · MSc year 1, DCI · supervised by Prof. Themis Palpanas · with Kaci Sofiane Agouni and Aghilas Ould Braham

Filling the gaps of 3,127 electricity meters

To fill gaps in a time series, does deep learning beat a classical method?

0.262
MAE for GPU STL, on known households
0.279
on 1,098 unseen households, with 50% of values masked
12,864
readings per series: one every 30 minutes for 268 days
5
methods compared, including 3 deep models
01 · The data

Two scenarios, one challenge

Smart meters record each household's electricity consumption every 30 minutes. Some readings were masked; the goal is to reconstruct them with the lowest possible mean absolute error (MAE), as part of an internal Kaggle challenge in the master's program.

ScenarioTrainingTestMasked
Step A3,127 complete householdsthe same households30%
Step Bthe same 3,127 households1,098 new households50%

Consumption values are highly skewed, with long tails. Before any method, values outside [Q1 − 1.5·IQR, Q3 + 1.5·IQR] are clipped to the nearest quartile, so that outlier readings do not distort learning.

02 · The methods

From the simplest to the deepest

MethodPrinciple
Nearest neighborcopy the values of the closest training household, measured on the observed positions
GPU STLtrend + seasonality decomposition, rewritten in PyTorch
LSTM autoencoderreconstruction of masked windows
PConv U-Net1D inpainting: convolutions only see observed values
Transformerself-supervised masked imputation, trained on several GPUs

STL, the winner, fits in a few lines. It starts from the nearest-neighbor imputation, then repeats 30 times:

  1. estimate the trend with a moving average, computed as a 1D convolution on GPU;
  2. estimate seasonality as the median residual at each phase of the cycle, for example daily (48 readings) or weekly (336);
  3. rebuild trend + seasonality and write the result back only at the missing positions.
03 · Results

The simplest method wins

Step A: same households, 30% masked Step B: new households, 50% masked
GPU-accelerated STLtrend + seasonal decomposition 0.262 · 0.279
Nearest neighborcopy of the closest household 0.312 · 0.311
PConv U-Netpartial convolutions 0.327 · 0.333
Transformerself-supervised masking 0.331 · 0.344
LSTM autoencodermasked windows 0.335 · 0.356
Fig. 1 — MAE in both scenarios, lower is better. STL comes first in both, including on households it has never seen.
Training and prediction time in minutes: a few minutes for nearest neighbor and STL, up to about 170 minutes of training for the Transformer
Fig. 2 — Training and prediction time, in minutes. STL and nearest neighbor need no training; the Transformer trains for nearly three hours.
04 · Why

The right inductive bias beats a big model

  • The structure of the data. Electricity consumption is made of a trend plus daily and weekly cycles: exactly what STL assumes.
  • The scale. 3,127 series of 12,864 points, tens of millions of time steps: high-capacity models converge poorly within a reasonable number of epochs.
  • The budget. To fit on 4 GPUs, the deep models' depth, dimensions and sequence lengths had to be reduced, at the cost of their representational power.

Deep models remain an option, but they would need more compute, a lighter architecture or multi-stage pretraining to beat this baseline.