Classify observations using linear classification model
Statistics and Machine Learning Toolbox / Classification
The ClassificationLinear Predict block classifies observations using a
linear classification object (
ClassificationLinear) for binary
Import a trained classification object into the block by specifying the name of a workspace variable that contains the object. The input port x receives an observation (predictor data), and the output port label returns predicted class labels for the observation. You can add the optional output port score, which returns predicted class scores or posterior probabilities.
label — Predicted class label
fixed point |
score — Predicted class scores or posterior probabilities
Predicted class scores or posterior probabilities, returned as a 1-by-2 row
vector. If the model was trained using a logistic learner, the classification scores
are posterior probabilities. The classification score
represents the posterior probability that the observation in x
belongs to class
To check the order of the classes, use the
property of the linear model specified by Select trained machine
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 TypesFixed-Point Operational Parameters
For linear classification models, the raw classification score for classifying the observation x into the positive class is defined by
f(x) = xβ+b
β is the estimated column vector of coefficients, and
b is the estimated scalar bias. The linear classification model object
specified by Select trained machine learning
model contains the coefficients and bias in the
Bias properties, respectively.
The raw classification score for classifying x into the negative class is –f(x). The software classifies observations into the class that yields the positive score.
If the linear classification model uses no score transformations, then the raw
classification score is the same as the classification score. If the model consists of
logistic regression learners, then the software applies the
transformation to the raw classification scores.
Score data type determines the data type of the classification score.
Raw score data type determines the data type of the raw classification score f if the model uses a score transformation other than
Inner product data type determines the data type of xβ.
When deciding whether to use the ClassificationLinear Predict block in the
Statistics and Machine Learning Toolbox™ library or a MATLAB Function block with the
predict function, consider the
If you use the Statistics and Machine Learning Toolbox library block, you can use the Fixed-Point Tool (Fixed-Point Designer) to convert a floating-point model to fixed point.
Support for variable-size arrays must be enabled for a MATLAB Function block with the
If you use a MATLAB Function block, you can use MATLAB functions for preprocessing or post-processing before or after predictions in the same MATLAB Function block.
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Design and simulate fixed-point systems using Fixed-Point Designer™.
Introduced in R2023a
- ClassificationECOC Predict | ClassificationSVM Predict | RegressionLinear Predict | IncrementalClassificationLinear Predict | IncrementalClassificationLinear Fit