# Regression Learner

Train regression models to predict data using supervised machine learning

## Description

The Regression Learner app trains regression models to predict data. Using this app, you can explore your data, select features, specify validation schemes, train models and optimize hyperparameters, assess results, and investigate how specific predictors contribute to model predictions. Perform automated training to search for the best regression model type, including linear regression models, regression trees, Gaussian process regression models, support vector machines, efficiently trained linear regression models, kernel approximation models, ensembles of regression trees, and neural network regression models. To compare models, use the metric results table and view results plots in the app.

Perform supervised machine learning by supplying a known set of observations of input data (predictors) and known responses. Use the observations to train a model that generates predicted responses for new input data. You can then check model performance using a test data set. To understand how the model uses predictors to make predictions, use global and local interpretability tools, such as partial dependence plots, LIME values, and Shapley values.

To use the trained model with new data, you can export the model to the workspace,
Simulink^{®}, and MATLAB^{®}
Production Server™. You can generate MATLAB code to recreate the trained model outside of the app and explore
programmatic regression and further customization of the model training workflow. Export
the model training code to Experiment
Manager to perform additional tasks, such as changing the training data,
adjusting hyperparameter search ranges, and running custom training experiments.

### More

### Required Products

MATLAB

Statistics and Machine Learning Toolbox™

## Open the Regression Learner App

MATLAB Toolstrip: On the

**Apps**tab, under**Machine Learning**, click the app icon.MATLAB command prompt: Enter

`regressionLearner`

.

## Examples

- Train Regression Models in Regression Learner App
- Select Data and Validation for Regression Problem
- Automated Regression Model Training
- Choose Regression Model Options
- Feature Selection and Feature Transformation
- Visualize and Assess Model Performance in Regression Learner
- Explain Model Predictions for Regression Models Trained in Regression Learner App
- Export Regression Model to Predict New Data

## Programmatic Use

`regressionLearner`

`regressionLearner`

opens the Regression Learner app or brings
focus to the app if it is already open.

`regressionLearner(Tbl,ResponseVarName)`

`regressionLearner(Tbl,ResponseVarName)`

opens the Regression
Learner app and populates the New Session from Arguments dialog box with the data
contained in the table `Tbl`

. The
`ResponseVarName`

argument, specified as a character vector or
string scalar, is the name of the variable in `Tbl`

that contains
the response values. The remaining variables in `Tbl`

are the
predictor variables.

`regressionLearner(Tbl,Y)`

`regressionLearner(Tbl,Y)`

opens the Regression Learner app and
populates the New Session from Arguments dialog box with the predictor variables in
the table `Tbl`

and the response values in the numeric vector
`Y`

.

`regressionLearner(X,Y)`

`regressionLearner(X,Y)`

opens the Regression Learner app and
populates the New Session from Arguments dialog box with the
*n*-by-*p* predictor matrix
`X`

and the *n* response values in the vector
`Y`

. Each row of `X`

corresponds to one
observation, and each column corresponds to one variable. The length of
`Y`

and the number of rows of `X`

must be
equal.

`regressionLearner(___,Name,Value)`

`regressionLearner(___,Name,Value)`

specifies
cross-validation options using one or more of the following name-value arguments in
addition to any of the input argument combinations in the previous syntaxes. For
example, you can specify `"KFold",10`

to use a 10-fold
cross-validation scheme.

`"CrossVal"`

, specified as`"on"`

(default) or`"off"`

, is the cross-validation flag. If you specify`"on"`

, then the app uses 5-fold cross-validation. If you specify`"off"`

, then the app uses resubstitution validation.You can override the

`"CrossVal"`

cross-validation setting by using the`"Holdout"`

or`"KFold"`

name-value argument. You can specify only one of these arguments at a time.`"Holdout"`

, specified as a numeric scalar in the range [0.05,0.5], is the fraction of the data used for holdout validation. The app uses the remaining data for training (and testing, if specified).`"KFold"`

, specified as a positive integer in the range [2,50], is the number of folds to use for cross-validation.`"TestDataFraction"`

, specified as a numeric scalar in the range [0,0.5], is the fraction of the data reserved for testing.

`regressionLearner(filename)`

`regressionLearner(filename)`

opens the Regression Learner app
with the previously saved session in `filename`

. The
`filename`

argument, specified as a character vector or string
scalar, must include the name of a Regression Learner session file and the path to
the file, if it is not in the current folder. The file must have the extension
`.mat`

.

## Limitations

Regression Learner does not support model deployment to MATLAB Production Server in MATLAB Online™.

## Version History

**Introduced in R2017a**

## See Also

### Apps

### Functions

`fitrtree`

|`fitlm`

|`stepwiselm`

|`fitrsvm`

|`fitrlinear`

|`fitrgp`

|`fitrkernel`

|`fitrensemble`

|`fitrnet`

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

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 MathWorks 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)