Main Content

IncrementalRegressionLinear Predict

Predict responses using incremental linear regression model

Since R2023b

  • IncrementalRegressionLinear Predict Block Icon

Libraries:
Statistics and Machine Learning Toolbox / Incremental Learning / Regression / Linear

Description

The IncrementalRegressionLinear Predict block predicts responses for streaming data using a trained linear regression model returned as the output of an IncrementalRegressionLinear Fit block.

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 mdl receives a bus signal that represents an incremental learning model fit to streaming data. The input port x receives a chunk of predictor data (observations), and the output port yfit returns predicted responses for the chunk. The optional output port CanPredict returns the prediction status of the trained model.

Examples

Ports

Input

expand all

Incremental learning model (incrementalRegressionLinear) fit to streaming data, specified as a bus signal (see Composite Signals (Simulink)).

Chunk of predictor data, 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 observations in the predictor data are oriented along the rows of x.

Note

The block supports only numerical 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

Output

expand all

Chunk of predicted responses, returned as a floating-point vector. For more details, see Predicted response and the YHat argument of the predict object function.

Note

If you specify an estimation period when you create mdl, then the predicted responses are zero during the estimation period.

Data Types: single | double

Model status for prediction, returned as logical 0 (false) or 1 (true).

Note

If you specify an estimation period when you create mdl, then the model status is 0 (false) during the estimation period.

Dependencies

To enable this port, select the check box for Add output port for status of trained machine learning model on the Main tab of the Block Parameters dialog box.

Parameters

expand all

Main

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, or cell). If you supply training data in a table, the predictors must be numeric (double or single). To include categorical predictors in a model, preprocess them by using dummyvar 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"

Select the check box to include the output port CanPredict in the IncrementalRegressionLinear Predict block. This check box does not appear if the workspace already contained an incremental linear regression model named linearMdl capable of prediction when you created the IncrementalRegressionLinear Predict block. Alternatively, you can specify to include the output port CanPredict by selecting the IncrementalRegressionLinear Predict block in the Simulink® workspace and entering set_param(gcb,ShowOutputCanPredict="on") at the MATLAB command line.

Programmatic Use

Block Parameter: ShowOutputCanPredict
Type: character vector
Values: "off" | "on"
Default: "off"

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"

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 Predict 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 Parameters

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"

Specify whether overflows saturate or wrap.

ActionRationaleImpact on OverflowsExample

Select this check box (on).

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 int8 (signed 8-bit integer) data type can represent is 127. Any block operation result greater than this maximum value causes overflow of the 8-bit integer. With the check box selected, the block output saturates at 127. Similarly, the block output saturates at a minimum output value of –128.

Clear this check box (off).

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 int8 (signed 8-bit integer) data type can represent is 127. Any block operation result greater than this maximum value causes overflow of the 8-bit integer. With the check box cleared, the software interprets the value causing the overflow as int8, which can produce an unintended result. For example, a block result of 130 (binary 1000 0010) expressed as int8 is –126.

Programmatic Use

Block Parameter: SaturateOnIntegerOverflow
Type: character vector
Values: "off" | "on"
Default: "off"

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"
Data Type

Specify the data type for the yfit output. The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType.

When you select Inherit: auto, the block uses a rule that inherits a data type.

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: OutDataTypeStr
Type: character vector
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"

Specify the lower value of the yfit output range that Simulink checks.

Simulink uses the minimum value to perform:

Note

The Output data type Minimum parameter does not saturate or clip the actual yfit output. To do so, use the Saturation (Simulink) block instead.

Programmatic Use

Block Parameter: OutMin
Type: character vector
Values: "[]" | scalar
Default: "[]"

Specify the upper value of the yfit output range that Simulink checks.

Simulink uses the maximum value to perform:

Note

The Output data type Maximum parameter does not saturate or clip the actual yfit output. To do so, use the Saturation (Simulink) block instead.

Programmatic Use

Block Parameter: OutMax
Type: character vector
Values: "[]" | scalar
Default: "[]"

Specify the data type for the inner product term of the predicted response. The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType.

When you select Inherit: Inherit via internal rule, the block uses an internal rule to determine the inner product data type. The internal rule chooses a data type that optimizes numerical accuracy, performance, and generated code size, while taking into account the properties of the embedded target hardware. The software cannot always optimize efficiency and numerical accuracy at the same time.

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: InnerProductDataTypeStr
Type: character vector
Values: "Inherit: Inherit via internal rule" | "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: "double"

Specify the lower value of the inner product term range that Simulink checks.

Simulink uses the minimum value to perform:

Note

The Inner product data type Minimum parameter does not saturate or clip the actual inner product term value.

Programmatic Use

Block Parameter: InnerProductOutMin
Type: character vector
Values: "[]" | scalar
Default: "[]"

Specify the upper value of the inner product term range that Simulink checks.

Simulink uses the maximum value to perform:

Note

The Inner product data type Maximum parameter does not saturate or clip the actual inner product term value.

Programmatic Use

Block Parameter: InnerProductOutMax
Type: character vector
Values: "[]" | scalar
Default: "[]"

Block Characteristics

Data Types

Boolean | double | fixed point | half | integer | single

Direct Feedthrough

yes

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

More About

expand all

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 R2023b

expand all