IncrementalRegressionLinear Fit
Libraries:
Statistics and Machine Learning Toolbox /
Incremental Learning /
Regression /
Linear
Description
The IncrementalRegressionLinear Fit block fits a configured incremental model
for linear regression (incrementalRegressionLinear
) to streaming data.
Import an initial linear regression model object into the block by specifying the name of a
workspace variable that contains the object. The input port x
receives a chunk of predictor data (observations), and the input port
y receives a chunk of responses to which the model is fit. The
output port mdl returns an updated
incrementalRegressionLinear
model. The optional input port
w receives a chunk of observation weights.
Examples
Perform Incremental Learning Using IncrementalRegressionLinear Fit and Predict Blocks
Perform incremental learning with the IncrementalRegressionLinear Fit block and predict responses with the IncrementalRegressionLinear Predict block.
- Since R2023b
- Open Live Script
Configure Simulink Template for Rate-Based Incremental Linear Regression
Configure the Simulink Rate-Based Incremental Learning template to perform incremental linear regression.
- Since R2024a
- Open Live Script
Configure Simulink Template for Conditionally Enabled Incremental Linear Regression
Configure the Simulink Enabled Execution Incremental Learning template to perform incremental linear regression.
- Since R2024a
- Open Live Script
Ports
Input
x — Chunk of predictor data
numeric matrix
Chunk of predictor data to which the model is fit, specified as a numeric matrix. The
orientation of the variables and observations is specified by Predictor data observation
dimension. The default orientation is rows
, which
indicates that the observations in the predictor data are oriented along the rows of
x.
The length of the observation responses y and the number of
observations in x must be equal;
y(
is the
response of observation j (row or column) in
x.j
)
The following restrictions apply:
The number of predictor variables in x must be equal to the
NumPredictors
property value of the initial model. If the number of predictor variables in the streaming data changes fromNumPredictors
, the block issues an error.The IncrementalRegressionLinear Fit block supports only numeric input predictor data. If your input data includes categorical data, you must prepare an encoded version of the categorical data. Use
dummyvar
to convert each categorical variable to a numeric matrix of dummy variables. Then, concatenate all dummy variable matrices and any other numeric predictors. For more details, see Dummy Variables.
Data Types: single
| double
| half
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
y — Chunk of responses
numeric vector
Chunk of responses to which the model is fit, specified as a numeric vector.
The length of the observation responses y and the number of
observations in x must be equal;
y(j)
is the response of
observation j (row or column) in
x. For more information, see Predicted Response.
Data Types: single
| double
| half
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
w — Chunk of observation weights
vector of positive values
Chunk of observation weights, specified as a vector of positive values. The IncrementalRegressionLinear Fit block weights the observations in x with the corresponding values in w. The size of w must be equal to the number of observations in x.
Dependencies
To enable this port, select the check box for Add input port for observation weights on the Main tab of the Block Parameters dialog box.
Data Types: single
| double
Output
mdl — Updated incremental learning model parameters
bus signal
Updated parameters of the incremental learning model fit to streaming data (including
Beta
and Bias
), returned as a bus signal (see Composite
Signals
(Simulink)).
Parameters
Main
Select initial machine learning model — Initial incremental linear regression model
linearMdl
(default) | incrementalRegressionLinear
model object
Specify the name of a workspace variable that contains the configured
incrementalRegressionLinear
model object.
The following restrictions apply:
The predictor data cannot include categorical predictors (
logical
,categorical
,char
,string
, orcell
). If you supply training data in a table, the predictors must be numeric (double
orsingle
). To include categorical predictors in a model, preprocess them by usingdummyvar
before fitting the model.The
NumPredictors
property of the initial model must be a positive integer scalar, and must be equal to the number of predictors in x.Before R2024a: the
Solver
property of the initial model must be"scale-invariant"
.
Programmatic Use
Block Parameter:
InitialLearner |
Type: workspace variable |
Values:
incrementalRegressionLinear model
object |
Default:
"linearMdl" |
Add input port for observation weights — Add second input port for observation weights
off
(default) | on
Select the check box to include the input port w for observation weights in the IncrementalRegressionLinear Fit block.
Programmatic Use
Block Parameter:
ShowInputWeights |
Type: character vector |
Values:
"off" | "on" |
Default:
"off" |
Predictor data observation dimension — Observation dimension of predictor data
rows
(default) | columns
Specify the observation dimension of the predictor data. The default value is
rows
, which indicates that observations in the predictor data are
oriented along the rows of x.
Programmatic Use
Block Parameter:
ObservationsIn |
Type: character vector |
Values:
"rows" | "columns" |
Default:
"rows" |
Sample time (–1 for inherited) — Option to specify sample time
–1
(default) | scalar
Specify the discrete interval between sample time hits or specify another type of sample
time, such as continuous (0
) or inherited (–1
). For more
options, see Types of Sample Time (Simulink).
By default, the IncrementalRegressionLinear Fit block inherits sample time based on the context of the block within the model.
Programmatic Use
Block Parameter:
SystemSampleTime |
Type: string scalar or character vector |
Values: scalar |
Default:
"–1" |
Data Types
Fixed-Point Operational ParametersInteger rounding mode — Rounding mode for fixed-point operations
Floor
(default) | Ceiling
| Convergent
| Nearest
| Round
| Simplest
| Zero
Specify the rounding mode for fixed-point operations. For more information, see Rounding Modes (Fixed-Point Designer).
Block parameters always round to the nearest representable value. To control the rounding of a block parameter, enter an expression into the mask field using a MATLAB® rounding function.
Programmatic Use
Block Parameter:
RndMeth |
Type: character vector |
Values:
"Ceiling" | "Convergent" | "Floor" | "Nearest" | "Round" | "Simplest" |
"Zero" |
Default:
"Floor" |
Saturate on integer overflow — Method of overflow action
off
(default) | on
Specify whether overflows saturate or wrap.
Action | Rationale | Impact on Overflows | Example |
---|---|---|---|
Select this check box
( | Your model has possible overflow, and you want explicit saturation protection in the generated code. | Overflows saturate to either the minimum or maximum value that the data type can represent. | The maximum value that the |
Clear this check box
( | You want to optimize the efficiency of your generated code. You want to avoid overspecifying how a block handles out-of-range signals. For more information, see Troubleshoot Signal Range Errors (Simulink). | Overflows wrap to the appropriate value that the data type can represent. | The maximum value that the |
Programmatic Use
Block Parameter:
SaturateOnIntegerOverflow |
Type: character vector |
Values:
"off" | "on" |
Default:
"off" |
Lock output data type setting against changes by the fixed-point tools — Prevention of fixed-point tools from overriding data type
off
(default) | on
Select this parameter to prevent the fixed-point tools from overriding the data type you specify for the block. For more information, see Use Lock Output Data Type Setting (Fixed-Point Designer).
Programmatic Use
Block Parameter:
LockScale |
Type: character vector |
Values:
"off" | "on" |
Default:
"off" |
Beta data type — Data type of linear coefficient estimates
Inherit: auto
(default) | double
| single
| half
| int8
| uint8
| int16
| uint16
| int32
| uint32
| int64
| uint64
| boolean
| fixdt(1,16,0)
| fixdt(1,16,2^0,0)
| <data type expression>
Specify the data type for the linear coefficient estimates (beta) in the
mdl output bus signal. The type can be inherited, specified directly,
or expressed as a data type object such as Simulink.NumericType
.
For more information about data types, see Control Data Types of Signals (Simulink).
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the data type attributes. For more information, see Specify Data Types Using Data Type Assistant (Simulink).
Programmatic Use
Block Parameter:
BetaDataTypeStr |
Type: character vector or string |
Values: "Inherit: auto" |
"double" | "single" | "half" |
"int8" | "uint8" | "int16" |
"uint16" | "int32" | "uint32" |
"int64" | "uint64" | "boolean"
| "fixdt(1,16,0)" | "fixdt(1,16,2^0,0)" |
"<data type expression>" |
Default: "Inherit: auto"
|
Beta data type Minimum — Minimum value of beta for range checking
[]
(default) | scalar
Specify the lower value of the beta range that Simulink® checks.
Simulink uses the minimum value to perform:
Parameter range checking for some blocks (see Specify Minimum and Maximum Values for Block Parameters (Simulink)).
Simulation range checking (see Specify Signal Ranges (Simulink) and Enable Simulation Range Checking (Simulink)).
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes, such as software-in-the-loop (SIL) mode or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
The Beta data type Minimum parameter does not saturate or clip the actual beta estimate. To do so, use the Saturation (Simulink) block instead.
Programmatic Use
Block Parameter:
BetaOutMin |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Beta data type Maximum — Maximum value of beta for range checking
[]
(default) | scalar
Specify the upper value of the beta range that Simulink checks.
Simulink uses the maximum value to perform:
Parameter range checking for some blocks (see Specify Minimum and Maximum Values for Block Parameters (Simulink)).
Simulation range checking (see Specify Signal Ranges (Simulink) and Enable Simulation Range Checking (Simulink)).
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes, such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
The Beta data type Maximum parameter does not saturate or clip the actual beta estimate. To do so, use the Saturation (Simulink) block instead.
Programmatic Use
Block Parameter:
BetaOutMax |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Bias data type — Data type of intercept estimates
Inherit: auto
(default) | double
| single
| half
| int8
| uint8
| int16
| uint16
| int32
| uint32
| int64
| uint64
| boolean
| fixdt(1,16,0)
| fixdt(1,16,2^0,0)
| <data type expression>
Specify the data type for the intercept estimates (bias) in the mdl
output bus signal. The type can be inherited, specified directly, or expressed as a data type
object such as Simulink.NumericType
.
For more information about data types, see Control Data Types of Signals (Simulink).
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the data type attributes. For more information, see Specify Data Types Using Data Type Assistant (Simulink).
Programmatic Use
Block Parameter:
BiasDataTypeStr |
Type: character vector or string |
Values: "Inherit: auto" |
"double" | "single" | "half" |
"int8" | "uint8" | "int16" |
"uint16" | "int32" | "uint32" |
"int64" | "uint64" | "boolean"
| "fixdt(1,16,0)" | "fixdt(1,16,2^0,0)" |
"<data type expression>" |
Default: "Inherit: auto"
|
Bias data type Minimum — Minimum value of bias for range checking
[]
(default) | scalar
Specify the lower value of the bias range that Simulink checks.
Simulink uses the minimum value to perform:
Parameter range checking for some blocks (see Specify Minimum and Maximum Values for Block Parameters (Simulink)).
Simulation range checking (see Specify Signal Ranges (Simulink) and Enable Simulation Range Checking (Simulink)).
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes, such as software-in-the-loop (SIL) mode or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
The Bias data type Minimum parameter does not saturate or clip the actual bias estimate. To do so, use the Saturation (Simulink) block instead.
Programmatic Use
Block Parameter:
BiasOutMin |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Bias data type Maximum — Maximum value of bias for range checking
[]
(default) | scalar
Specify the upper value of the bias range that Simulink checks.
Simulink uses the maximum value to perform:
Parameter range checking for some blocks (see Specify Minimum and Maximum Values for Block Parameters (Simulink)).
Simulation range checking (see Specify Signal Ranges (Simulink) and Enable Simulation Range Checking (Simulink)).
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes, such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
The Bias data type Maximum parameter does not saturate or clip the actual bias estimate. To do so, use the Saturation (Simulink) block instead.
Programmatic Use
Block Parameter:
BiasOutMax |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Internal states data type — Data type of internal states
Inherit: auto
(default) | double
| single
| half
| int8
| uint8
| int16
| uint16
| int32
| uint32
| int64
| uint64
| boolean
| fixdt(1,16,0)
| fixdt(1,16,2^0,0)
| <data type expression>
Specify the data type for the internal states in the mdl output
bus signal. The type can be inherited, specified directly, or expressed as a data type
object such as Simulink.NumericType
.
For more information about data types, see Control Data Types of Signals (Simulink).
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the data type attributes. For more information, see Specify Data Types Using Data Type Assistant (Simulink).
Programmatic Use
Block Parameter:
StatesDataTypeStr |
Type: character vector or string |
Values: "Inherit: auto"
| "double" | "single" |
"half" | "int8" |
"uint8" | "int16" |
"uint16" | "int32" |
"uint32" | "int64" |
"uint64" | "boolean" |
"fixdt(1,16,0)" | "fixdt(1,16,2^0,0)"
| "<data type expression>" |
Default: "Inherit: auto"
|
Internal states data type Minimum — Minimum value of internal states for range checking
[]
(default) | scalar
Specify the lower value of the internal states range that Simulink checks.
Simulink uses the minimum value to perform:
Parameter range checking for some blocks (see Specify Minimum and Maximum Values for Block Parameters (Simulink)).
Simulation range checking (see Specify Signal Ranges (Simulink) and Enable Simulation Range Checking (Simulink)).
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes, such as software-in-the-loop (SIL) mode or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
The Internal states data type Minimum parameter does not saturate or clip the actual internal states. To do so, use the Saturation (Simulink) block instead.
Programmatic Use
Block Parameter:
StatesOutMin |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Internal states data type Maximum — Maximum value of internal states for range checking
[]
(default) | scalar
Specify the upper value of the internal states range that Simulink checks.
Simulink uses the maximum value to perform:
Parameter range checking for some blocks (see Specify Minimum and Maximum Values for Block Parameters (Simulink)).
Simulation range checking (see Specify Signal Ranges (Simulink) and Enable Simulation Range Checking (Simulink)).
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes, such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
The Internal states data type Maximum parameter does not saturate or clip the actual internal states. To do so, use the Saturation (Simulink) block instead.
Programmatic Use
Block Parameter:
StatesOutMax |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Mu data type — Data type of predictor means
Inherit: auto
(default) | double
| single
| half
| int8
| uint8
| int16
| uint16
| int32
| uint32
| int64
| uint64
| boolean
| fixdt(1,16,0)
| fixdt(1,16,2^0,0)
| <data type expression>
Specify the data type for the predictor means (mu) in the mdl output
bus signal. The type can be inherited, specified directly, or expressed as a data type object
such as Simulink.NumericType
.
If you do not specify Standardize
="true"
when you
create the initial model, then the IncrementalRegressionLinear Fit block sets mu to
0
.
For more information about data types, see Control Data Types of Signals (Simulink).
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the data type attributes. For more information, see Specify Data Types Using Data Type Assistant (Simulink).
Programmatic Use
Block Parameter:
MuDataTypeStr |
Type: character vector or string |
Values: "Inherit: auto" |
"double" | "single" | "half" |
"int8" | "uint8" | "int16" |
"uint16" | "int32" | "uint32" |
"int64" | "uint64" | "boolean"
| "fixdt(1,16,0)" | "fixdt(1,16,2^0,0)" |
"<data type expression>" |
Default: "Inherit: auto"
|
Mu data type Minimum — Minimum value of mu for range checking
[]
(default) | scalar
Specify the lower value of the mu range that Simulink checks.
Simulink uses the minimum value to perform:
Parameter range checking for some blocks (see Specify Minimum and Maximum Values for Block Parameters (Simulink)).
Simulation range checking (see Specify Signal Ranges (Simulink) and Enable Simulation Range Checking (Simulink)).
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes, such as software-in-the-loop (SIL) mode or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
The Mu data type Minimum parameter does not saturate or clip the actual mu value. To do so, use the Saturation (Simulink) block instead.
Programmatic Use
Block Parameter:
MuOutMin |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Mu data type Maximum — Maximum value of mu for range checking
[]
(default) | scalar
Specify the upper value of the mu range that Simulink checks.
Simulink uses the maximum value to perform:
Parameter range checking for some blocks (see Specify Minimum and Maximum Values for Block Parameters (Simulink)).
Simulation range checking (see Specify Signal Ranges (Simulink) and Enable Simulation Range Checking (Simulink)).
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes, such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
The Mu data type Maximum parameter does not saturate or clip the actual mu value. To do so, use the Saturation (Simulink) block instead.
Programmatic Use
Block Parameter:
MuOutMax |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Sigma data type — Data type of predictor standard deviations
Inherit: auto
(default) | double
| single
| half
| int8
| uint8
| int16
| uint16
| int32
| uint32
| int64
| uint64
| boolean
| fixdt(1,16,0)
| fixdt(1,16,2^0,0)
| <data type expression>
Specify the data type for the predictor standard deviations (sigma) in the
mdl output bus signal. The type can be inherited, specified directly,
or expressed as a data type object such as Simulink.NumericType
.
If you do not specify Standardize
=true
when you
create the initial model, then the IncrementalRegressionLinear Fit block sets sigma to
0
.
For more information about data types, see Control Data Types of Signals (Simulink).
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the data type attributes. For more information, see Specify Data Types Using Data Type Assistant (Simulink).
Programmatic Use
Block Parameter:
SigmaDataTypeStr |
Type: character vector or string |
Values: "Inherit: auto" |
"double" | "single" | "half" |
"int8" | "uint8" | "int16" |
"uint16" | "int32" | "uint32" |
"int64" | "uint64" | "boolean"
| "fixdt(1,16,0)" | "fixdt(1,16,2^0,0)" |
"<data type expression>" |
Default: "Inherit: auto"
|
Sigma data type Minimum — Minimum value of sigma for range checking
[]
(default) | scalar
Specify the lower value of the sigma range that Simulink checks.
Simulink uses the minimum value to perform:
Parameter range checking for some blocks (see Specify Minimum and Maximum Values for Block Parameters (Simulink)).
Simulation range checking (see Specify Signal Ranges (Simulink) and Enable Simulation Range Checking (Simulink)).
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes, such as software-in-the-loop (SIL) mode or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
The Sigma data type Minimum parameter does not saturate or clip the actual sigma value. To do so, use the Saturation (Simulink) block instead.
Programmatic Use
Block Parameter:
SigmaOutMin |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Sigma data type Maximum — Maximum value of sigma for range checking
[]
(default) | scalar
Specify the upper value of the sigma range that Simulink checks.
Simulink uses the maximum value to perform:
Parameter range checking for some blocks (see Specify Minimum and Maximum Values for Block Parameters (Simulink)).
Simulation range checking (see Specify Signal Ranges (Simulink) and Enable Simulation Range Checking (Simulink)).
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes, such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
The Sigma data type Maximum parameter does not saturate or clip the actual sigma value. To do so, use the Saturation (Simulink) block instead.
Programmatic Use
Block Parameter:
SigmaOutMax |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
More About
Predicted Response
For linear regression models, the predicted response for the observation x is
y = xβ+b
β is the estimated column vector of coefficients, and
b is the estimated scalar bias. The linear regression model
object specified by Select initial
machine learning model contains the coefficients and bias in the
Beta
and Bias
properties, respectively.
β and b correspond to
Beta
and Bias
, respectively.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.
Version History
Introduced in R2023bR2024a: Incremental linear blocks support additional solvers
Starting in R2024a, the IncrementalRegressionLinear Fit block additionally supports initial machine
learning models where Solver
is "sgd"
or
"asgd"
.
See Also
Blocks
Objects
Functions
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)