ClassificationSVM Predict - Classify observations using support vector machine (SVM) classifier for one-class and

        binary classification - Simulink ([original](http://www.mathworks.com/help/stats/classificationsvmpredict.html)) ([raw](?raw))

Classify observations using support vector machine (SVM) classifier for one-class and binary classification

Since R2020b

Libraries:
Statistics and Machine Learning Toolbox / Classification

Description

The ClassificationSVM Predict block classifies observations using an SVM classification object (ClassificationSVM or CompactClassificationSVM) for one-class and two-class (binary) classification.

Import a trained SVM 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 a predicted class label for the observation. You can add the optional output port score, which returns predicted class scores or posterior probabilities.

Examples

Ports

Input

expand all

Predictor data, specified as a column vector or row vector of one observation.

The variables in x must have the same order as the predictor variables that trained the SVM model specified by**Select trained machine learning model**.

If you set 'Standardize',true in fitcsvm when training the SVM model, then the ClassificationSVM Predict block standardizes the values of x using the means and standard deviations in the Mu andSigma properties (respectively) of the SVM model.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point

Output

expand all

Predicted class label, returned as a scalar.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated

Predicted class scores or posterior probabilities, returned as a scalar for one-class learning or a 1-by-2 vector for two-class learning.

Dependencies

To enable this port, select the check box for Add output port for predicted class scores on theMain tab of the Block Parameters dialog box.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point

Parameters

expand all

Main

Data Types

Fixed-Point Operational Parameters

Data Type

Block Characteristics

Data Types Boolean | double enumerated fixed point half integer single
Direct Feedthrough yes
Multidimensional Signals no
Variable-Size Signals no
Zero-Crossing Detection no

More About

expand all

The SVM classification score for classifying observation x is the signed distance from x to the decision boundary ranging from -∞ to +∞. A positive score for a class indicates that x is predicted to be in that class. A negative score indicates otherwise.

The positive class classification score f(x) is the trained SVM classification function. f(x) is also the numerical predicted response for x, or the score for predicting x into the positive class.

where (α1,...,αn,b) are the estimated SVM parameters, G(xj,x) is the dot product in the predictor space between x and the support vectors, and the sum includes the training set observations. The negative class classification score for x, or the score for predicting_x_ into the negative class, is –f(x).

If G(xj,x) = xj_′_x (the linear kernel), then the score function reduces to

s is the kernel scale and β is the vector of fitted linear coefficients.

For more details, see Understanding Support Vector Machines.

The posterior probability is the probability that an observation belongs in a particular class, given the data.

For SVM, the posterior probability is a function of the score_P_(s) that observation j is in class k = {-1,1}.

The prior probability of a class is the assumed relative frequency with which observations from that class occur in a population.

The data types of internal model parameters are synchronized to the data type of the enabled score output port. If thescore output port is not enabled, the model parameter data types are synchronized to other internal data types.

Tips

Alternative Functionality

You can use a MATLAB Function block with the predict object function of an SVM classification object (ClassificationSVM or CompactClassificationSVM). For an example, see Predict Class Labels Using MATLAB Function Block.

When deciding whether to use the ClassificationSVM Predict block in the Statistics and Machine Learning Toolbox™ library or a MATLAB Function block with the predict function, consider the following:

Extended Capabilities

Version History

Introduced in R2020b

expand all

Starting in R2021a, the default data type value and the supported data types of theLabel data type parameter depend on the labels used in the model specified by Select trained machine learning model. The default value is Inherit: Inherit via back propagation for numeric and logical labels, andInherit: auto for nonnumeric labels.

If you specified Label data type as Inherit: Inherit via back propagation for nonnumeric labels or Inherit: Inherit from 'Constant value', then change the value toInherit: auto.

Starting in R2021a, the default value of the parameters Score data type and Raw score data type isInherit: auto.

Starting in R2021a, the Kernel data type parameter does not support inherited options. You can specify Kernel data type as a supported data type name or data type object.

See Also

Blocks

Objects

Functions

Topics