ML & Data Science

Household Power Forecasting

Time-series forecasting

MSc Data Science · Machine Learning coursework · Coventry University

Forecasting daily household power consumption, and finding which family of models actually wins.

Role
Data Scientist
Year
2025
Focus
Time-series forecasting
Stack
9 technologies
  • XGBoost
  • Random Forest
  • LightGBM
  • SARIMAX
  • Prophet
  • LSTM
  • N-BEATS
  • PyTorch
  • Pandas
  • 0.0125

    Test RMSE (XGBoost)

  • 0.998

    Test R² (XGBoost)

  • 0.77%

    Test MAPE (XGBoost)

  • 0.2614

    Best classical RMSE (LSTM)

  • 2.07M

    Minute-level readings

  • 10

    Models compared

Utilities and households need reliable short-term demand forecasts for grid planning, pricing, and energy advice. Raw smart-meter data is noisy: gaps from outages, extreme spikes, and strong daily, weekly, and seasonal cycles. The question is which model family handles all of that best.

The UCI Individual Household Electric Power Consumption dataset has 2,075,259 minute-level readings from December 2006 to November 2010. About 1.25% of rows were missing, always across all seven measurement columns at once, which points to whole-meter outages rather than single sensor faults.

Resampling to daily means cut the missing days to just 9 (0.62%), which were filled with forward-fill then linear interpolation. IQR flagged 4.63% of readings as outliers (above 3.36 kW, up to 11.12 kW). Instead of deleting genuine high-use days, they were winsorised to the upper bound.

I engineered 46 columns: calendar features, lags from 1 to 1,440 days, and rolling means, standard deviations, minimums, and maximums over 5 to 1,440 days. A strict chronological split kept the future unseen: 1,292 training days, 60 validation days, and a 60-day test window (28 Sep to 26 Nov 2010).

Five course-taught models (Naïve, 7-day moving average, Prophet, LSTM, SARIMA) were compared with five advanced ones (Random Forest, XGBoost, LightGBM, SARIMAX, N-BEATS). Every run's metrics and artifacts are saved with timestamps, and the best model is recorded for deployment.

Workflow

  1. 01

    Load

    2,075,259 minute-level readings across seven power, voltage, and sub-metering columns.

  2. 02

    Resample & impute

    daily mean

    Aggregate to daily, then forward-fill and linear interpolation. Zero missing values remain.

  3. 03

    Winsorise

    IQR

    Cap 4.63% outliers at 3.36 kW so spikes inform without dominating.

  4. 04

    Engineer

    46 columns

    Calendar features, lags (1–1,440 days), and rolling statistics (5–1,440 days).

  5. 05

    Split

    chronological

    Train 1,292 days, validation 60, test 60. No shuffling, no look-ahead.

  6. 06

    Classical models

    Naïve, 7-day moving average, Prophet, LSTM, SARIMA.

  7. 07

    Advanced models

    Random Forest, XGBoost, LightGBM, SARIMAX(1,1,1)(0,1,1,7), N-BEATS, with safe exogenous filtering and early stopping.

  8. 08

    Evaluate & select

    MAE · RMSE · MAPE · R²

    Ranked on validation and test, then error analysis by weekday, season, peak load, and outlier days.

Exploration, diagnostics, and forecasts from the project notebooks. Tap any figure to zoom.

  1. Fig. 01 · EDA

    Four years of daily demand

    After resampling, the series shows a clear yearly cycle: high in winter, low in summer, with a sharp dip each August.

  2. Fig. 02 · Seasonality

    The daily rhythm

    Consumption climbs in the morning, dips midday, and peaks in the evening when people cook and heat. Evening hours also have the widest spread.

  3. Fig. 03 · Seasonality

    Weekdays vs weekends

    Weekends run higher and spread usage through the day. That's why day-of-week is a key calendar feature.

  4. Fig. 04 · Seasonality

    Monthly and yearly patterns

    Winter months use roughly twice the power of summer. Long lags (up to 1,440 days) let the models see this yearly cycle.

  5. Fig. 05 · IQR · Winsorisation

    Outliers worth keeping

    94,907 readings (4.63%) sit above 3.36 kW, averaging 4.30 kW. These are real high-use periods, so they were capped rather than removed.

  6. Fig. 06 · Decomposition

    Trend, season, and noise

    Separating the series shows a smooth yearly trend, a regular weekly cycle, and large residuals. Much of the variance is short-term and non-linear.

  7. Fig. 07 · ACF · PACF

    Autocorrelation

    Strong, slowly decaying autocorrelation with spikes every 7 days justifies the lag features and the weekly seasonal term in SARIMA(X).

  8. Fig. 08 · Evaluation design

    A chronological split

    Training, then 60 validation days, then a final untouched 60-day test window. Every model is judged on the same unseen future.

  9. Fig. 09 · Classical

    Prophet

    Prophet tracks the weekly shape and gives uncertainty bands, but its smooth forecasts miss day-to-day swings (test RMSE 0.302, R² −0.28).

  10. Fig. 10 · Classical · deep learning

    LSTM

    The best course-taught model (test RMSE 0.261, MAE 0.191). It learns non-linear temporal patterns but still under-reacts to sharp peaks.

  11. Fig. 11 · Advanced · selected

    XGBoost

    Forecast and actual lines almost overlap on both splits. Test RMSE 0.0125, MAE 0.0086, MAPE 0.77%, R² 0.998.

  12. Fig. 12 · Interpretability

    What XGBoost relies on

    Global intensity dominates, followed by recent power lags and rolling statistics. Sub-metering and calendar features add finer detail.

  13. Fig. 13 · Comparison

    Classical models compared

    LSTM leads every metric among the course-taught models. SARIMA struggles with non-stationary, high-variance data.

  14. Fig. 14 · Comparison

    All ten models

    The tree ensembles and SARIMAX are an order of magnitude more accurate than everything else. N-BEATS comes last, without enough data or epochs to converge.

Test RMSE (lower is better)

60-day test window, 28 Sep – 26 Nov 2010

  • XGBoost0.0125
  • Random Forest0.0136
  • SARIMAX0.0177
  • LightGBM0.0191
  • LSTM0.2614
  • Moving average (7-day)0.3005
  • Prophet0.3019
  • SARIMA0.3468
  • Naïve0.3631
  • N-BEATS0.5797

Test MAPE (lower is better)

Error as a percentage of actual demand

  • XGBoost0.77%
  • Random Forest1.00%
  • SARIMAX1.22%
  • LightGBM1.23%
  • LSTM16.8%
  • Moving average (7-day)20.4%
  • Prophet20.8%
  • SARIMA22.6%
  • Naïve23.4%
  • N-BEATS39.4%
  • Day of week: errors are lower on weekdays with stable routines and higher on weekends. Tree ensembles cope best because they encode day-of-week directly.
  • Month and season: transitions between months bring changes in temperature and daylight. Tree models adapt quickly; Prophet handles smooth seasonality but not within-month variability.
  • Peak vs off-peak: evening ramps and spikes are where XGBoost pulls ahead, splitting on ramp-rate and sub-meter signals. Random Forest averages away rare spikes, and Prophet/SARIMA smooth over them.
  • Outlier days: blackouts, holidays, and equipment failures drive most of the MAPE. Robust losses (Huber, quantile), holiday regressors, and residual control charts would reduce their impact.
  • XGBoost: the main production model. Most accurate on every test metric, fast to predict, and explainable with feature importance and SHAP. Needs care to keep unsafe lags out.
  • Random Forest: the stable backup, with the best validation RMSE (0.0106) and little tuning needed. Larger memory footprint and slightly weaker on extreme spikes.
  • SARIMAX: a lightweight, interpretable baseline that is useful for scenario analysis, but weaker under regime change (test RMSE 0.0177).
  • LightGBM: efficient and competitive (test RMSE 0.0191). A good choice when training speed and memory matter, or inside a stacked ensemble.
  • LSTM, Prophet, SARIMA: transparent, quick baselines. N-BEATS is experimental here and worth revisiting with longer histories and GPU training.
  • Only about four years of data from a single household, which limits long-term trend learning and generalisation.
  • No temperature, humidity, or holiday data, which are known drivers of household demand.
  • Imputation may smooth over small changes during outage gaps.
  • Consumption patterns reveal when people are home, asleep, or using appliances. Real deployments need anonymisation, aggregation, GDPR compliance, and care that forecast-driven pricing doesn't disadvantage some groups.
  • Multi-step forecasting with sequence-to-sequence LSTMs, Temporal Convolutional Networks, or Transformers.
  • Exogenous signals: weather APIs, daylight, occupancy, and IoT smart-meter feeds.
  • Hybrid models, for example Prophet for seasonality and XGBoost on the residuals, or Bayesian model averaging.
  • Rolling-origin cross-validation, drift monitors (PSI, residual CUSUM), and scheduled monthly retraining.