Machine Learning Forecasting for Electricity Demand Using Climate and Socioeconomic Data in Sub-Saharan Africa
No Thumbnail Available
Date
2026-09-30
Authors
Journal Title
Journal ISSN
Volume Title
Publisher
Uganda Christian University
Abstract
Electricity demand forecasting is important for energy planning, resource allocation, and infrastructure development. In Sub-Saharan Africa, forecasting electricity demand is particularly difficult because electricity usage is driven by rapid population growth, economic changes, urbanisation, and climate variability, while data quality and availability remain inconsistent across countries. Although previous studies showed that climate and socioeconomic variables are associated with electricity demand, many focused on short-term forecasting, single-country analysis, or datasets from developed regions.
This study examined how far integrated climate and socioeconomic data improves annual electricity demand forecasting across 47 Sub-Saharan African countries. Country-level panel time-series data was collected from publicly available sources including the World Bank, Our World in Data, and the ERA5 climate reanalysis dataset, covering the period from 2000 to 2021. The methodology included data integration and preprocessing, normality testing, temporal feature engineering, a two-stage feature selection process, and the training and comparison of six forecasting models: Linear Regression, Fixed Effects Panel Regression, Dynamic Fixed Effects Panel Regression, Random Forest, XGBoost, and LightGBM. Model performance was evaluated using Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), Mean Absolute Percentage Error (MAPE), and the coefficient of determination (R^2). A decision-support dashboard was also developed using Streamlit to visualise electricity demand forecasts, trends, and key demand drivers.
The results showed that lagged electricity demand was by far the strongest predictor of future demand, with the one-year lag achieving a near-perfect Pearson correlation of 0.999 with the target variable. Among structural climate and socioeconomic predictors, population size and its three-year rolling mean were the strongest predictors of electricity demand, followed by the three-year rolling mean of temperature, the interaction between population and electricity access, and the temperature-urbanisation interaction. Linear Regression on the full multivariate feature set achieved the best overall test set performance, with a log-scale MAPE of 6.01% and an R^2 of 0.996 (note: all metrics are on the log-transformed demand scale, not in original TWh units), and was selected as the final model for the dashboard. The study confirms that annual electricity demand in Sub-Saharan Africa is extremely persistent, lagged demand provides most of the predictive power in the model. Climate and socioeconomic variables contain substantial structural information about demand patterns when historical demand is unavailable, but contribute little additional one-year-ahead predictive accuracy once lagged demand is already included. This distinction between predictive accuracy and structural explanation is the core finding of the study.
Description
Keywords
Electricity demand forecasting, Sub-Saharan Africa, Machine learning, Panel time-series data, Climate and socioeconomic variables, Feature engineering, Walk-forward validation, Decision-support dashboard
