Skip to content
Julen Somet García
FRENES
← All missions

Data DAT-07 · Jun 2025

Forecasting a household's electricity consumption

Hour-by-hour forecast of a house's consumption from four years of measurements, comparing six models with naive baselines. Done during my semester at the West University of Timișoara, then corrected.

Role
Individual data mining project, West University of Timișoara
Stack
  • Python
  • pandas
  • scikit-learn
  • XGBoost
  • LightGBM
  • statsmodels
  • Jupyter
−16%error compared with simply repeating the previous hour (Random Forest)
0.33 kWmean error over 2010, for an average consumption of 1.07 kW
÷ 2the error at 7 am, when the model anticipates waking up (0.41 kW versus 0.79 kW)
Result of the project Forecasting a household's electricity consumption

AThe question

Can we forecast a house's electricity consumption for the next hour from its history? And do machine learning models really do better than the simplest rule: repeating the previous hour's consumption?

BThe data

The UCI dataset “Individual household electric power consumption”: 2,075,259 measurements, one per minute, from a house in Sceaux between December 2006 and November 2010. It contains active and reactive power, voltage, current intensity and three sub-meters. 1.25% of the minutes are missing, in blocks of up to five days.

CThe method

Exploration reveals three cycles: consumption nearly doubles in winter and collapses every August, it peaks around 8 pm, and at weekends it stays high all day. The data is aggregated by hour, then each forecast relies on the previous 24 hours, the same hour the week before, the hour, the day and the month. Models learn on 2007 to 2009 and are evaluated on the eleven months of 2010. Linear regression, Random Forest, XGBoost, LightGBM, a neural network and seasonal ARIMA are compared with three naive baselines, with the same information for all.

DIn charts

Four years of consumption: a marked yearly cycle, with a dip every August.
Four years of consumption: a marked yearly cycle, with a dip every August.
On the left, the typical day on weekdays and at weekends. On the right, the model halves the error at 7 am, on waking up, but does barely better than persistence in the middle of the day.
On the left, the typical day on weekdays and at weekends. On the right, the model halves the error at 7 am, on waking up, but does barely better than persistence in the middle of the day.

EWhat I take from it

Random Forest, XGBoost and LightGBM come out level, with LightGBM training twenty times faster. The first version of the project concluded that the LSTM was promising without ever having evaluated the models. It also normalised the data over the whole period, test set included, and compared ARIMA under different conditions from the other models. Once these errors were fixed and a naive baseline added, the gain is real but modest: sudden peaks, when an appliance switches on, cannot be guessed from past consumption. The next variables to add would be the weather and the occupants' presence.