User Stories

Administrador del Mercado Mayorista Develops AI-Based Models for Predicting Electricity Demand


Forecast electricity demand across Guatemala to increase grid stability, maximize power generated from renewable resources, and lower energy costs


Use MATLAB to develop machine learning and deep learning algorithms that use historical load measurements, outside temperatures, and other data to predict hour-by-hour demand


  • Prediction error halved
  • Models updated rapidly for pandemic-related changes
  • Production tool developed and deployed in 6 months

“Before starting this project, we had no experience with AI and little experience with programming in MATLAB. Machine learning and deep learning are complex topics, but MATLAB made the project straightforward for us with toolboxes that are easy to learn and use.”

Lead engineer, Administrador del Mercado Mayorista
Demand prediction tool.

Demand prediction tool.

The Administrador del Mercado Mayorista (AMM) in Guatemala is responsible for operating the national grid and for administering the country’s wholesale electricity market. To fulfill these responsibilities, AMM must have accurate hour-by-hour predictions of electricity demand.

AMM recently created a tool in MATLAB® that uses deep learning and machine learning models to predict short-term electricity demand. Despite having no prior experience with AI, a small team of AMM engineers completed development in just 6 months. The tool has enabled AMM to reduce prediction error by more than 50%.

“The versatility of MATLAB and the ease with which we could use MATLAB toolboxes for machine learning and deep learning to solve complex issues were key advantages for our team,” says a lead engineer at AMM. “With this new tool we’ll be able to maximize hydroelectric resources, optimize the use of reserves, and minimize costly payments to international energy exchanges.”


In the past, AMM predicted demand by performing a mathematical regression based on historical data. This approach was labor-intensive and did not take the effects of ambient temperature into account. Since even a two-degree shift in ambient temperature can change demand by up to 150 MW, day-to-day weather changes reduced the accuracy of the demand forecast considerably.

AMM wanted to apply machine learning or deep learning models that could predict demand based on both historical demand and other factors, such as the weather forecast. They needed to evaluate a variety of model types to find the ones that would work best with their data. The prediction models would need to be deployed as a standalone tool that was easy for analysts to use.


AMM engineers started by reviewing a MathWorks webinar on electricity load and price forecasting (47:43) and exploring the example MATLAB code. Working in MATLAB, the team then cleaned and preprocessed hourly demand and temperature data for the past 17 years, removing outliers caused by blackouts and similar anomalies.

The team evaluated a wide range of machine learning models using Statistics and Machine Learning Toolbox™. They trained each model on a data set that included past demand, expected hour-by-hour temperatures, the position of the sun, and day of the week. After comparing results from the models, they selected a bagged decision tree for its training speed and accuracy in predicting hour-by-hour demand.

The team built an artificial neural network (ANN) using the Deep Network Designer app in Deep Learning Toolbox™. They trained the ANN using the data set they had used to train the bagged decision tree model. The engineers then compared the results produced by the network and by the model.

They found that, while the results were nearly equivalent, there were some situations in which one outperformed the other. For example, on major holidays or following abrupt temperature changes, the ANN performed better, whereas under nominal conditions, the machine learning model performed better. As a result, they decided to use both.

During the pandemic, the historical data provided less predictive value, since there was no history of lockdown measures. The team used holiday results to approximate demand until the model had enough data to work correctly.

The engineers created a graphical interface for the tool and packaged it with the ANN and the bagged decision tree model as a standalone application.

The short-term electricity demand prediction tool has been in production at AMM for more than a year. This version generates predictions for the next day and for the next 10 days. AMM engineers are currently extending the tool to generate medium-term predictions (1–3 months ahead) and long-term predictions (17 months ahead).


  • Prediction error halved. The AMM short-term electricity demand prediction tool achieved a total mean absolute percentage error (MAPE) of 1.7%, less than half the 3.7% MAPE achieved with the traditional method. The key to this improvement was the use of MATLAB based deep learning and machine learning models that factored in ambient temperature.
  • Models updated rapidly for pandemic-related changes. The tool quickly adjusted to and incorporated new trends resulting from the pandemic. This was because the team had programmed the tool in MATLAB to retrain the models with current data each time it was used.
  • Production tool developed and deployed in 6 months. The engineers attribute this rapid deployment to the webinars and tutorials they used to jumpstart the project and to the speed with which they learned to implement sophisticated machine learning and deep learning models in MATLAB.