- Licence
- CC BY-SA 4.0Adapted from www.appropedia.org
- Languages
- English
Every summer, rising temperatures bring electricity shortages to many places, including Tabriz in Iran. This project, published on Appropedia, tries to explain and predict Tabriz's summer load profile, meaning its electricity consumption, from weather data and a few other features. Predicting load, the author writes, helps both utilities and consumers manage the system. Its best model, a tuned Gaussian process regression, reached an R-squared of 0.92 on test data.

Demand against temperature. Figure by MirAli Ghassemi on Appropedia, CC BY-SA 4.0.
Building the data
The author listed three families of prediction methods: time series, component decomposition, and artificial intelligence (machine learning, deep learning and reinforcement learning), and chose supervised machine learning.
- Weather. Using Python and the weather.com API, the author pulled hourly temperature, wind velocity, cloud cover and relative humidity. Cleaning, done in Excel, looked for missing data, duplicates, invalid data and outliers, and filled gaps by linear interpolation.
- Load. With a friend's help the author obtained 90 days of load data as CSV files from 48 substations, then used the Pandas library to sum the substations' hourly loads.
- Features. Date and hour were combined with weather and load in one file. The author replaced dates with days of the week, labeled days as weekdays or weekends, and grouped the 24 hours into night, working hours and evening, because load looked distinct in each.
What the data showed
Temperature was roughly normally distributed, ranging from 11 to 39 degrees Celsius but mostly between 25 and 30, while wind velocity and relative humidity looked more like chi-squared distributions. Humidity had a strong inverse linear relationship with temperature.

Temperature against hour. Figure by MirAli Ghassemi on Appropedia, CC BY-SA 4.0.

Humidity against temperature. Figure by MirAli Ghassemi on Appropedia, CC BY-SA 4.0.
Demand was higher on weekdays, with a larger spread, and lower at night than during working hours. It was highest in the evening: offices are closed, but people at home are cooling and watching TV. Wind speed and cloud cover showed no clear relationship with demand, while temperature did, mainly, the author says, because of widespread use of air conditioners.
A cubic polynomial fitted to hourly averages followed the average temperature well. Consumption peaks at about 2 p.m. Temperature keeps rising after that, but demand drops, which the author attributes to most offices closing at 2 p.m.

Fitted curves. Figure by MirAli Ghassemi on Appropedia, CC BY-SA 4.0.
Modeling
Because the data set was small, the author used MATLAB's toolbox, which has a point-and-click interface. The data were split, with 75 percent of records for training and 25 percent for testing, and every available algorithm was run. Models were compared on the test data by root mean square error (RMSE) and mean absolute error (MAE), where smaller is better, so as to avoid overfitting.
| Model | RMSE | MAE |
|---|---|---|
| Gaussian process regression, exponential | 11.5 | 8.1 |
| Gaussian process regression, Matern 5/2 | 11.5 | 8.1 |
| Ensemble, bagged trees | 12.0 | 8.5 |
| Support vector machine, medium Gaussian | 12.2 | 8.5 |
| Tree, medium | 12.3 | 9.0 |
| Stepwise linear regression | 15.1 | 11.4 |
| Linear regression, linear | 17.09 | 13.2 |
Gaussian process regression, bagged trees and support vector machines did best, in the author's reading. Hyperparameter optimization of the Gaussian process regression brought RMSE to 10.5 and MAE to 7.3, with an R-squared of 0.92. R-squared runs from 0 to 1, and closer to 1 means the model explains the data better.

Actual against predicted demand: the points cluster around the red line. Figure by MirAli Ghassemi on Appropedia, CC BY-SA 4.0.
What could come next
Because the data form a time series, the author suggests adding lagged features such as temperature and demand at earlier hours, since both may have delayed effects.
Sources
- "Electricity Demand Modeling Based on Weather Data Using ML," Appropedia, by its contributors (figures credited to MirAli Ghassemi) (https://www.appropedia.org/Electricity_Demand_Modeling_Based_on_Weather_Data_Using_ML), licensed under CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/). Changed here: rewritten in hubnx's own words; the results table is shortened; the project box and edit links are left out. Figures are credited in their captions.
Comments




