Forecast Electrical Load Using the Regression Learner App
From the series: Machine Learning in Finance
The Regression Learner app lets you explore your data, select features, specify validation schemes, optimize hyperparameters, and assess model performance to predict your data without needing to write any code.
You can export regression models to the MATLAB® workspace or generate MATLAB code to integrate models into applications.
The app takes menial workflows and tasks like setting up the validation, picking the relevant predictors, and picking the optimal model and tuning it and makes them interactive, saving you time. It also gives you full transparency into what's happening under the hood and automates the workflow by automatically generating code.
Regression Learner App in the Statistics and Machine Learning toolbox lets you train multiple models and choose the best model to predict your data, without needing to write any code.
You can also use the app to explore your data, select features, specify validation schemes, optimize hyperparameters, and assess model performance.
This example will use the app to model the amount of electricity required to support an electric grid – also referred to as the “load” – and use that model to make predictions about a future load.
You can find the Regression Learner app in the app gallery under machine learning and deep learning.
You can also open it directly from the MATLAB command line.
Start a new session, and then select the dataset you want to use. Based on the data types of the variables therein, the app will automatically assign them as predictors or as responses. However, you can always change their roles if necessary. You can also deselect variables irrelevant to predicting a response, which will save on training time.
The default automatic cross-validation option protects against overfitting. In this example, where we have lots of data, hold-out validation works well.
Next, you’ll be able to explore which machine learning model makes the most sense with your data.
There are many models from which you can choose: linear regression models, regression trees, Gaussian process regression models, support vector machines, and ensembles of regression trees.
If you already have an idea of what kinds of models are best suited for your data, you can train them one-by-one, or select a group of models to train. If you’re unsure, just select them all, start training, and look at the one that gives you the best initial performance.
You can see the models in the history list along with the Root-Mean Square Error (or RMSE). RMSE represents the model’s performance, or fitness, against your data. The lower the error, the better the fitness. The app will automatically highlight the model with the lowest error.
In this example, the model with the lowest RMSE is the Matern 5/2 GPR.
When you select a model, you’ll be able to use various plots to see more details about its performance.
As an example, the predicted vs actual plot helps you understand how well this particular model makes predictions for different response values. A perfect regression model has a predicted response equal to the true response, so all the points lie on a diagonal line. The vertical distance from the line to any point is the error of the prediction for that point.
To further optimize the model, you can tune its hyperparameters. The app will try different combinations of hyperparameter values by using an optimization scheme that seeks to minimize the model error.
To do this, select the Optimizable model corresponding to your model type, in this case, the Optimizable GPR.
The app will iterate through all these combinations of hyperparameters for GPR models. The visualization shows how the error decreases as different combinations of hyperparameters are evaluated. When it’s done, the app will highlight the best one with the lowest RMSE.
After you are satisfied with the training and tuning process, you can export your model back to the MATLAB workspace or generate MATLAB code.
Exporting to the workspace enables you to use the trained model to make predictions on new data.
Generating the MATLAB code for this model enables you to integrate it into machine learning applications, and enables your colleagues to quickly replicate your results.
To learn more about regression learning and download example datasets, click on the Help icon in the top right corner of the app.
Download Code and Files
Related Products
Learn More
Featured Product
Statistics and Machine Learning Toolbox
Related Videos:
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other bat365 country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)