IncrementalClassificationKernel Predict
Libraries:
Statistics and Machine Learning Toolbox /
Incremental Learning /
Classification /
Kernel
Description
The IncrementalClassificationKernel Predict block classifies observations using a trained kernel classification model returned as the output of an IncrementalClassificationKernel Fit block.
Import an initial kernel classification model object into the IncrementalClassificationKernel Predict 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 label returns predicted class labels for the chunk. The optional output port score returns the predicted class scores or posterior probabilities and the optional output port CanPredict returns the prediction status of the trained model.
Examples
Perform Incremental Learning Using IncrementalClassificationKernel Fit and Predict Blocks
Perform incremental learning with the IncrementalClassificationKernel Fit block and predict labels with the IncrementalClassificationKernel Predict block.
- Since R2024b
- Open Live Script
Ports
Input
mdl — Incremental learning model
bus signal
Incremental learning model (incrementalClassificationKernel
) fit to streaming data, specified as a bus
signal (see Composite Signals (Simulink)).
x — Chunk of predictor data
numeric matrix
Chunk of predictor data, specified as a numeric matrix.
Note
The 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
Output
label — Chunk of predicted class labels
column vector
Chunk of predicted class labels, returned as a column vector. The label
label(i)
represents the class yielding the highest score for
the observation x(i
). For more details, see
the label
output argument of the predict
object function.
If you specify an estimation period when you create mdl, the predicted class labels are the majority class during the estimation period. This class which makes up the largest proportion of the training labels in x.
Data Types: single
| double
| half
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
| enumerated
score — Predicted class scores or posterior probabilities
matrix
Predicted class scores or posterior probabilities, returned as a matrix. If the
model was trained using a logistic learner, the classification scores are posterior
probabilities. The classification score score(i)
represents the
posterior probability that the observation in x belongs to class
i
. For more details, see Classification Score.
To check the order of the classes, use the ClassNames
property of the kernel classification model specified by Select initial machine
learning model.
Note
If you specify an estimation period when you create mdl, then the predicted class scores are zero during the estimation period.
Dependencies
To enable this port, select the check box for Add output port for predicted class scores on the Main tab of the Block Parameters dialog box.
Data Types: single
| double
| half
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
CanPredict — Model status
0
(false
) | 1
(true
)
Model status for prediction, returned as numeric or 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
To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.
Main
Select initial machine learning model — Initial incremental kernel classification model
kernelMdl
(default) | incrementalClassificationKernel
model object
Specify the name of a workspace variable that contains the configured incrementalClassificationKernel
model object.
When you create the initial 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
ScoreTransform
property of the initial model cannot be"invlogit"
or an anonymous function.The
NumPredictors
property of the initial model must be a positive integer scalar, and must be equal to the number of predictors in x.
Programmatic Use
Block Parameter:
InitialLearner |
Type: character vector or string |
Values:
incrementalClassificationKernel object name |
Default:
"kernelMdl" |
Add output port for predicted class scores — Add second output port for predicted class scores
off
(default) | on
Select the check box to include the output port score in the IncrementalClassificationKernel Predict block.
Programmatic Use
Block Parameter:
ShowOutputScore |
Type: character vector or string |
Values:
"off" | "on" |
Default:
"off" |
Add output port for status of trained machine learning model — Add third output port for model status
off
(default) | on
Select the check box to include the output port CanPredict in
the IncrementalClassificationKernel Predict block. This check box does
not appear if the workspace already contains an incremental kernel classification
model named kernelMdl
, capable of prediction, when you create the
IncrementalClassificationKernel Predict block. Alternatively, you can
specify to include the output port CanPredict by selecting
the IncrementalClassificationKernel 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 or string |
Values:
"off" | "on" |
Default:
"off" |
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 IncrementalClassificationKernel 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 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" |
Label data type — Data type of label output
Inherit: Inherit via back propagation
| double
| single
| half
| int8
| uint8
| int16
| uint16
| int32
| uint32
| int64
| uint64
| boolean
| fixdt(1,16,0)
| fixdt(1,16,2^0,0)
| Enum: <class name>
| <data type expression>
Specify the data type for the label output. The type can be
inherited, specified as an enumerated data type, or
expressed as a data type object such as Simulink.NumericType
.
The supported data types depend on the labels used in the model specified by Select initial machine learning model.
If the model uses numeric or logical labels, the supported data types are
Inherit: Inherit via back propagation
(default),double
,single
,half
,int8
,uint8
,int16
,uint16
,int32
,uint32
,int64
,uint64
,boolean
, fixed point, and a data type object.If the model uses nonnumeric labels, the supported data types are
Enum: <class name>
and a data type object.
When you select an inherited option, the software behaves as follows:
Inherit: Inherit via back propagation
(default for numeric and logical labels) — Simulink automatically determines the Label data type of the block during data type propagation (see Data Type Propagation (Simulink)). In this case, the block uses the data type of a downstream block or signal object.Inherit: auto
(default for nonnumeric labels) — The block uses an autodefined enumerated data type variable. For example, suppose the workspace variable name specified by Select initial machine learning model ismyMdl
, and the class labels areclass 1
andclass 2
. Then, the corresponding label values aremyMdl_enumLabels.class_1
andmyMdl_enumLabels.class_2
. The block converts the class labels to valid MATLAB identifiers by using thematlab.lang.makeValidName
function.
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:
LabelDataTypeStr |
Type: character vector |
Values: "Inherit: Inherit via back
propagation" | "double" |
"single" | "half" |
"int8" | "uint8" |
"int16" | "uint16" |
"int32" | "uint32" |
"int64" | "uint64" |
"boolean" | "fixdt(1,16,0)" |
"fixdt(1,16,2^0,0)" | "Enum: <class
name>" | "<data type expression>" |
Default: "Inherit: Inherit via
back propagation" (for numeric and logical labels) |
"Inherit: auto" (for nonnumeric labels) |
Label data type Minimum — Minimum value of label output for range checking
[]
(default) | scalar
Specify the lower value of the label output 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 Label data type Minimum parameter does not saturate or clip the actual label output. To do so, use the Saturation (Simulink) block instead.
Dependencies
You can specify this parameter only if the model specified by Select initial machine learning model uses numeric labels.
Programmatic Use
Block Parameter:
LabelOutMin |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Label data type Maximum — Maximum value of label output for range checking
[]
(default) | scalar
Specify the upper value of the label output 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 Label data type Maximum parameter does not saturate or clip the actual label output. To do so, use the Saturation (Simulink) block instead.
Dependencies
You can specify this parameter only if the model specified by Select initial machine learning model uses numeric labels.
Programmatic Use
Block Parameter:
LabelOutMax |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Score data type — Data type of score output
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 score 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:
ScoreDataTypeStr |
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" |
Score data type Minimum — Minimum value of score output for range checking
[]
(default) | scalar
Specify the lower value of the score output 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 Score data type Minimum parameter does not saturate or clip the actual score output. To do so, use the Saturation (Simulink) block instead.
Programmatic Use
Block Parameter:
ScoreOutMin |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Score data type Maximum — Maximum value of score output for range checking
[]
(default) | scalar
Specify the upper value of the score output 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 Score data type Maximum parameter does not saturate or clip the actual score output. To do so, use the Saturation (Simulink) block instead.
Programmatic Use
Block Parameter:
ScoreOutMax |
Type: character vector |
Values: "[]" |
scalar |
Default: "[]" |
Kernel data type — Kernel computation data type
Inherit: Inherit via internal rule
(default) | double
| single
| half
| int8
| uint8
| int16
| uint16
| int32
| int64
| uint64
| uint32
| boolean
| fixdt(1,16,0)
| fixdt(1,16,2^0,0)
| <data type expression>
Specify the data type of the parameters for Gaussian kernel approximation computation.
The type can be 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 kernel 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:
KernelDataTypeStr |
Type: character vector |
Values: 'double' |
'single' | 'half' |
'int8' | 'uint8' |
'int16' | 'uint16' |
'int32' | 'uint32' |
'uint64' | 'int64' |
'boolean' | 'fixdt(1,16,0)' |
'fixdt(1,16,2^0,0)' | '<data type
expression>' |
Default: 'Inherit: Inherit via
internal rule' |
Kernel data type Minimum — Minimum kernel computation value for range checking
[]
(default) | scalar
Specify the lower value of the kernel computation internal variable 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 Kernel data type Minimum parameter does not saturate or clip the actual kernel computation value.
Programmatic Use
Block Parameter:
KernelOutMin |
Type: character vector |
Values: '[]' |
scalar |
Default: '[]' |
Kernel data type Maximum — Maximum kernel computation value for range checking
[]
(default) | scalar
Specify the upper value of the kernel computation internal variable 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 Kernel data type Maximum parameter does not saturate or clip the actual kernel computation value.
Programmatic Use
Block Parameter:
KernelOutMax |
Type: character vector |
Values: '[]' |
scalar |
Default: '[]' |
Inner product data type — Inner product term of the predicted response
Inherit: Inherit via internal rule
(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 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: "Inherit: Inherit via
internal rule" |
Inner product data type Minimum — Minimum of inner product term for range checking
[]
(default) | scalar
Specify the lower value of the inner product term 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 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: "[]" |
Inner product data type Maximum — Maximum of inner product term for range checking
[]
(default) | scalar
Specify the upper value of the inner product term 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 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 |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
More About
Classification Score
For kernel incremental learning models for binary classification, the
raw classification score for classifying the observation
x, a row vector, into the positive class (second class in
Mdl.ClassNames
) is
where
is a transformation of an observation for feature expansion.
β0 is the scalar bias.
β is the column vector of coefficients.
The raw classification score for classifying x into the negative
class (first class in Mdl.ClassNames
) is
–f(x). The software classifies observations into the
class that yields the positive score.
If the kernel classification model consists of logistic regression learners, then the
software applies the "logit"
score transformation to the raw
classification scores.
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 R2024b
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)