16/04/2026
We built a machine learning model to forecast Sri Lanka's monthly electricity demand. Here's how it works and what drives it. ๐ฑ๐ฐโก
๐ DATA SOURCES (all publicly available)
The model runs entirely on open data published by Sri Lankan and international institutions:
๐น CEB / PUCSL โ monthly generation by source (solar, wind, hydro, coal, oil)
๐น Central Bank of Sri Lanka โ quarterly real GDP, nominal GDP, tariff index, Services PMI, Construction PMI, industrial production index
๐น Open-Meteo โ Colombo hourly weather aggregated monthly: mean temp, afternoon peak temp, monthly max daily high, total rainfall, wind speed
๐น NOAA Climate Prediction Center โ Oceanic Niรฑo Index (ENSO), current month + 2-month forecast lead
๐น Department of Motor Traffic โ EV registrations converted to estimated monthly charging load
๐น Government Gazette โ weekday public holiday count per month
๐น SLSEA / CEB โ installed rooftop solar capacity (MW)
๐ง HOW THE MODEL WORKS
The model predicts net demand โ total generation minus solar โ using two components working together.
Component 1: Trend model (Ridge regression)
A regularized linear model trained on the economic and weather factors that drive demand up or down each month:
โช Real GDP at constant 2015 prices โ day-weighted monthly share of quarterly GDP
โช Electricity tariff index โ price elasticity (lower tariff = higher consumption)
โช Afternoon peak temperature (noonโ3pm) โ the main air conditioning load driver
โช 24-hour mean temperature โ ambient baseline
โช ENSO / ONI โ current month and 2-month lead (drought and rainfall outlook)
โช EV charging load โ structural new load added from 2025 onward
โช Rooftop solar capacity, NE monsoon flag, wind speed, cloud cover, holidays, COVID lockdown intensity, grid disruption severity
Component 2: GDP-adjusted seasonal index (two-pass)
A naive seasonal index simply averages demand by calendar month across years โ but those years had very different GDP levels (pre-crisis 2021 vs. the crash of 2022). That GDP variation leaks into the seasonal multipliers and weakens the model.
The fix: a two-pass GDP-purged seasonal index.
Pass 1 โ fit a rough trend model using a raw seasonal index.
Pass 2 โ compute the ratio of actual demand to the trend model's full prediction. Because the trend already accounts for GDP, tariffs and all economic drivers, this ratio isolates the pure calendar seasonal pattern, stripped of economic-cycle noise. Average per calendar month and normalize.
Final prediction = trend prediction ร GDP-adjusted seasonal multiplier
๐ HOW ACCURATE IS IT?
Accuracy is measured using Leave-One-Out (LOO) cross-validation. The model is retrained on all months except the one being predicted, so every forecast is genuinely out-of-sample.
โ
MAPE (Mean Absolute % Error): 1.87%
โ
MAE: 0.86 GWh/day
โ
Rยฒ: 0.880
๐
Trained on 62 months of data (January 2021 โ early 2026)
On a typical day consuming ~46 GWh, the monthly average forecast is within ยฑ0.86 GWh/day โ roughly a 3.8% error. That's tight enough for annual generation planning, fuel procurement decisions and detecting grid stress months before they arrive.
The net demand forecast feeds into a full dispatch cascade (solar + wind + mini hydro + major hydro โ coal โ oil), producing monthly grid health flags: grid stress risk, high-cost months and renewable surplus months.
๐ฎ WHAT DO YOU NEED TO PREDICT THE FUTURE?
To generate a forward forecast, you need these inputs โ all publicly available:
๐น Quarterly real GDP forecast โ CBSL Economic Projections
๐น Nominal GDP outlook โ CBSL Monetary Policy Reports
๐น Electricity tariff outlook โ PUCSL tariff orders
๐น Seasonal temperature outlook โ NOAA / DMC seasonal forecast
๐น ONI / ENSO forecast (2-month lead) โ NOAA CPC
๐น EV registration growth rate โ Motor Traffic Department
๐น Public holiday calendar โ Government Gazette
๐น Rooftop solar capacity projection โ SLSEA / PUCSL
Services PMI and Construction PMI are published monthly by CBSL in their Monthly Economic Indicators bulletin.
Model built with open-source Python (scikit-learn, pandas). All source data is publicly available from the institutions listed above.
๐งฉ KEY DEMAND DRIVERS
(within-year correlations with net electricity demand, 2021โ2026)
NE monsoon season โ r = โ0.45 (cooler months, lower AC load)
Grid disruption severity โ r = โ0.31 (forced demand suppression)
Afternoon peak temperature โ r = +0.26 (AC load driver)
COVID lockdown intensity โ r = โ0.18 (restricted economic activity)
Real GDP index โ r = +0.16 (economic activity level)
Electricity tariff index โ r = โ0.14 (higher price = lower consumption)
Weekday public holidays โ r = โ0.13 (fewer commercial operating hours)
ENSO / ONI index โ r = +0.11 (El Niรฑo = drier conditions = tighter supply)
Rooftop solar capacity โ r = โ0.08 (self-consumption reduces grid draw)