Skip to content

Repository files navigation

Machine Learning for Regression

View on File Exchange or Open in MATLAB Online

MATLAB Versions Tested

Curriculum Module

Created with R2026a. Compatible with R2026a and later releases.

Information

This curriculum module contains interactive MATLAB® live scripts that introduce machine learning for regression through baseline modeling, model improvement, tree-based methods, and optimization.

image_0.png

Background

You can use these live scripts as lecture demonstrations, in-class activities, or interactive assignments outside class. The lesson sequence starts with baseline linear regression, residual analysis, and cross-validation, then moves to feature engineering and regularization, then to regression trees and ensembles, and finally to optimization and gradient descent for iterative training.

Together, the four scripts show a disciplined regression workflow: start with a simple baseline, diagnose where it fails, improve the representation or model family, and evaluate changes using held-out error metrics. The instructions inside each live script guide students through the exercises one section at a time. To stop a running section midway, use the image_1.png Stop button in the RUN section of the Live Editor tab in the MATLAB Toolstrip.

Contact Us

Contact the MathWorks Educator Content Development Team if you would like to provide feedback, or if you have a question.

Prerequisites

This module does not assume any prior exposure to the subject of machine learning.

Getting Started

Accessing the Module

On MATLAB® Online™:

Use the image_2.png link to download the module. You will be prompted to log in or create a MathWorks account. The project will be loaded, and you will see an app with several navigation options to get you started.

On Desktop:

Download or clone this repository. Open MATLAB, navigate to the folder containing these scripts and double-click on MLforRegression.prj. It will add the appropriate files to your MATLAB path and open an app that asks you where you would like to start.

Ensure you have all the required products (listed below) installed. If you need to include a product, add it using the Add-On Explorer. To install an add-on, go to the Home tab and select image_3.png Add-Ons > Get Add-Ons.

Products

MATLAB® is used throughout. Tools from Statistics and Machine Learning Toolbox™, and System Identification Toolbox™ are used frequently as well.

Scripts

image_4.png
In this script, students will...
$\bullet$ recognize when simple linear regression is inadequate for real‑world data.
$\bullet$ evaluate and compare regression models using residuals and cross‑validation to assess generalization.
$\bullet$ describe the machine‑learning regression pipeline and its goal of generalization.
Academic disciplines
$\bullet$ Math
$\bullet$ Statistics
$\bullet$ Data Science
$\bullet$ Machine Learning

image_5.png
In this script, students will...
$\bullet$ explain how regression training can be framed as an optimization problem.
$\bullet$ compare SSE, MSE, and RMSE to interpret model prediction error.
$\bullet$ apply gradient descent updates to reduce a regression model’s cost function.
$\bullet$ evaluate how learning rate and iteration count affect convergence, oscillation, and model improvement.
Academic disciplines
$\bullet$ AI and Machine Learning
$\bullet$ Data Science
$\bullet$ Statistics
$\bullet$ Engineering

image_6.png
In this script, students will...
$\bullet$ apply feature transformations and compare engineered feature sets.
$\bullet$ use stepwise selection, Lasso, and Ridge to control model complexity.
$\bullet$ connect richer feature representations to generalization and interpretability.
Academic disciplines
$\bullet$ AI and Machine Learning
$\bullet$ Engineering
$\bullet$ Applied Mathematics

image_7.png
In this script, students will...
$\bullet$ compare different regression models and identify when each may be useful.
$\bullet$ explain how model structure affects predictions and interpretability.
$\bullet$ use visualizations and diagnostics to choose an appropriate model for a prediction task.
Academic disciplines
$\bullet$ AI and Machine Learning
$\bullet$ Data Science
$\bullet$ Statistics
$\bullet$ Engineering

Related Courseware Modules

image_8.png
Available on:
image_9.pngimage_10.png
GitHub

image_11.png
Available on:
image_12.pngimage_13.png
GitHub

Or feel free to explore our other modular courseware content.

Educator Resources

Contribute

Looking for more? Find an issue? Have a suggestion? Please contact the MathWorks Educator Content Development Team. If you want to contribute directly to this project, you can find information about how to do so in the CONTRIBUTING.md page on GitHub.

© Copyright 2026 The MathWorks, Inc

About

Interactive courseware module that introduces typical workflow, setup, and considerations involved in solving regression problems with machine learning.

Topics

Resources

Contributing

Security policy

Stars

24 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages