Work / Machine learning

Predicting prosumer energy imbalance

XGBoost pipeline for prosumer imbalance; 85% MAE reduction over a linear baseline.

§ 1 · Problem

Prosumers break the forecast

Enefit needed better forecasts of net energy behavior as more of its customers became prosumers — consuming and producing electricity at the same time. The task was to forecast consumption and production across 69 client categories over a 637-day time series, where the same customer can flip between drawing from the grid and feeding it.

§ 2 · Data

Kaggle competition data from Estonia

The data comes from the Enefit Predict Energy Behavior of Prosumers Kaggle competition, covering Estonian prosumers. Hourly energy readings, client metadata, electricity prices, gas prices, and county-mapped weather forecasts were merged into a single modeling table — most of the work was making five differently keyed sources line up on one hourly grid.

§ 3 · Method

25 predictors, five model families

From the merged table I engineered 25 predictors covering market prices, installed photovoltaic capacity, consumption points, time features, and 12 weather variables. Five model families — linear regression, LASSO, GAMs, decision trees, and XGBoost — were then compared on a held-out 80/20 split, scored on MAE and RMSE.

# XGBoost model with tuned hyperparameters
xgb_model <- xgboost(
  data = train_matrix,
  label = train_labels,
  nrounds = 500,
  max_depth = 6,
  eta = 0.1,
  subsample = 0.8,
  colsample_bytree = 0.8,
  objective = "reg:squarederror",
  eval_metric = "mae",
  early_stopping_rounds = 50,
  verbose = 0
)
§ 4 · Results

The jump from GAM to XGBoost

XGBoost reached a test MAE of 56.6 against 293.8 for linear regression — an 85% reduction over the linear baseline and an 81% reduction over the GAM, the next best model. The gap is not incremental: everything short of gradient boosting clusters around the same error, then XGBoost cuts it roughly fivefold.

XGBoost
56.6
GAM (next best)
292.6
Linear
293.8

■ gradient boosting   ■ additive baselines

Fig. 1 — Test MAE by model (lower is better): XGBoost cuts error roughly fivefold versus the next best model

Feature importance concentrated around hour, day, and installed solar capacity — the temporal cycle of demand and the physical capacity to produce.

§ 5 · Discussion

Why the additive models stalled

  • The additive models — linear, LASSO, even the GAM — all stalled near the same MAE; only a model that captures interactions between time and capacity broke through.
  • The importance ranking is physically sensible: hour and day carry the demand cycle, installed solar capacity carries the production side.
  • A temperature-vs-energy scatter made the split visible — production and consumption respond to weather in distinctly different ways, which is exactly why a single additive fit struggles on net behavior.