XGBoost pipeline for prosumer imbalance; 85% MAE reduction over a linear baseline.
Arya AmarnathBuilt R 4.3 / XGBoost / Quarto
§ 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 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.