Electricity Load Forecasting
This example demonstrates building and validating a short term electricity load forecasting model with MATLAB. The models take into account multiple sources of information including temperatures and holidays in constructing a day-ahead load forecaster. The models compared include Neural Networks and Regression Trees.
- Import Weather & Load Data
- Import list of holidays
- Generate Predictor Matrix
- Split the dataset to create a Training and Test set
- Build the Load Forecasting Model
- Initialize and Train Network
- Forecast using Neural Network Model
- Compare Forecast Load and Actual Load
- Examine Distribution of Errors
- Group Analysis of Errors
- Generate Weekly Charts
The data set used is a table of historical hourly loads and temperature observations from the New England ISO for the years 2004 to 2008. The weather information includes the dry bulb temperature and the dew point. This data set is imported from an Access database using the auto-generated function fetchDBLoadData.
A list of New England holidays that span the historical date range is imported from an Excel spreadsheet
The function genPredictors generates the predictor variables used as inputs for the model. For short-term forecasting these include
- Dry bulb temperature
- Dew point
- Hour of day
- Day of the week
- A flag indicating if it is a holiday/weekend
- Previous day's average load
- Load from the same hour the previous day
- Load from the same hour and same day from the previous week
If the goal is medium-term or long-term load forecasting, only the inputs hour of day, day of week, time of year and holidays can be used deterministically. The weather/load information would need to be specified as an average or a distribution
The dataset is divided into two sets, a training set which includes data from 2004 to 2007 and a test set with data from 2008. The training set is used for building the model (estimating its parameters). The test set is used only for forecasting to test the performance of the model on out-of-sample data.
The next few cells builds a Neural Network regression model for day-ahead load forecasting given the training data. This model is then used on the test data to validate its accuracy.
Initialize a default network of two layers with 20 neurons. Use the "mean absolute error" (MAE) performance metric. Then, train the network with the default Levenburg-Marquardt algorithm. For efficiency a pre-trained network is loaded unless a retrain is specifically enforced.
Once the model is built, perform a forecast on the independent test set.
Create a plot to compare the actual load and the predicted load as well as compute the forecast error. In addition to the visualization, quantify the performance of the forecaster using metrics such as mean average error (MAE), mean average percent error (MAPE) and daily peak forecast error.
Mean Average Percent Error (MAPE): 1.61% Mean Average Error (MAE): 243.18 MWh Daily Peak MAPE: 1.63%
In addition to reporting scalar error metrics such as MAE and MAPE, the plot of the distribution of the error and absolute error can help build intuition around the performance of the forecaster
To get further insight into the performance of the forecaster, we can visualize the percent forecast errors by hour of day, day of week and month of the year
Create a comparison of forecast and actual load for every week in the test set.