Main Content

# RegressionSVM Predict

Predict responses using support vector machine (SVM) regression model

• Library:
• Statistics and Machine Learning Toolbox / Regression

## Description

The RegressionSVM Predict block predicts responses using an SVM regression object RegressionSVM and its object function predict.

Import a trained SVM regression object into the block by specifying the name of a workspace variable that contains a RegressionSVM object. The input port X receives an observation (predictor data), and the output port Yfit returns a predicted response for the observation.

## Ports

### Input

expand all

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

#### Dependencies

• 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 fitrsvm when training the SVM model, then the RegressionSVM Predict block standardizes the values of X using the means and standard deviations in the Mu and Sigma properties (respectively) of the SVM model.

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

### Output

expand all

Predicted response, returned as a scalar.

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

## Parameters

expand all

### Main

Specify the name of a workspace variable that contains a RegressionSVM object or CompactRegressionSVM object.

When you train the SVM model by using fitrsvm, 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). Also, you cannot use the 'CategoricalPredictors' name-value pair argument. To include categorical predictors in a model, preprocess the categorical predictors by using dummyvar before fitting the model.

• The value of the 'ResponseTransform' name-value pair argument must be 'none' (default).

• The value of the 'KernelFunction' name-value pair argument must be 'gaussian', 'linear', or 'polynomial'.

#### Programmatic Use

 Block Parameter: TrainedLearner Type: workspace variable Values: RegressionSVM object | CompactRegressionSVM object Default: svmMdl

### Data Types

Fixed-Point Operational Parameters

Specify the rounding mode for fixed-point operations. For more information, see Rounding (Fixed-Point Designer).

Block parameters always round to the nearest representable value. To control the rounding of a block parameter, enter an expression using a MATLAB® rounding function into the mask field.

#### 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 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 overflow causing value 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 Signal Data Types (Simulink).

Click the 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' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'int64' | 'uint64' | 'fixdt(1,16)' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)' | '' Default: 'Inherit: auto'

Lower value of the Yfit output range that Simulink® checks.

Simulink uses the minimum value to perform:

Note

The Output minimum parameter does not saturate or clip the actual Yfit signal. Use the Saturation (Simulink) block instead.

#### Programmatic Use

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

Upper value of the Yfit output range that Simulink checks.

Simulink uses the minimum value to perform:

Note

The Output maximum parameter does not saturate or clip the actual Yfit signal. Use the Saturation (Simulink) block instead.

#### Programmatic Use

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

Specify the data type of a parameter for kernel computation.

The Kernel data type paramter specifies the data type of a different parameter depending on the type of kernel function of the specified SVM model. You specify the 'KernelFunction' name-value pair argument when training the SVM model.

'KernelFunction' valueData Type
'gaussian' or 'rbf'Kernel data type specifies the data type of the squared distance ${D}^{2}={‖x-s‖}^{2}$ for the Gaussian kernel $G\left(x,s\right)=\mathrm{exp}\left(-{D}^{2}\right)$, where x is the predictor data for an observation and s is a support vector.
'linear'Kernel data type specifies the data type for the output of the linear kernel function $G\left(x,s\right)=xs\text{'}$, where x is the predictor data for an observation and s is a support vector.
'polynomial'Kernel data type specifies the data type for the output of the polynomial kernel function $G\left(x,s\right)={\left(1+xs\text{'}\right)}^{p}$, where x is the predictor data for an observation, s is a support vector, and p is a polynomial kernel function order.

The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType.

When you select an inherited option, the software behaves as follows:

• Inherit: Inherit via internal rule — The block uses an internal rule to determine its 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 simultaneously optimize efficiency and numerical accuracy in all situations.

• Inherit: Keep MSB — Simulink chooses a data type that maintains the full range of the operation, and then reduces the precision to a size appropriate for the embedded target hardware. This rule never produces overflows.

Tip

For more efficient generated code, clear the Saturate on integer overflow parameter.

• Inherit: Match scaling — Simulink chooses a data type whose scaling matches the scaling of the input types, where the input refers to an input of a block under the mask. If the full range of the type does not fit on the embedded target hardware, the software reduces the range to yield a type that is appropriate for the embedded target hardware. This rule can produce overflows.

The software cannot simultaneously optimize code efficiency and numerical accuracy in all situations. If these internal rules do not meet your specific needs for numerical accuracy or performance, use one of the following options:

• Specify the data type explicitly.

• Specify a default data type explicitly, such as fixdt(1,32,16), and then use the Fixed-Point Tool to propose data types for your model. For more information, see fxptdlg (Fixed-Point Designer).

• Inherit: Inherit via back propagation — (Not recommended) The block uses the data type of a downstream block under the mask.

• Inherit: Same as first input — (Not recommended) This first input refers to the first input of a block under the mask.

For more information about data types, see Control Signal Data Types (Simulink).

Click the 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: 'Inherit: Inherit via internal rule | 'Inherit: Keep MSB' | 'Inherit: Match scaling' | 'double' | 'single' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'uint64' | 'int64' | 'fixdt(1,16)' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)' | '' Default: 'double'

Lower value of the kernel computation internal variable range that Simulink checks.

Simulink uses the minimum value to perform:

Note

The Kernel minimum parameter does not saturate or clip the actual kernel computation value signal.

#### Programmatic Use

 Block Parameter: KernelOutMin Type: character vector Values: '[ ]'| scalar Default: '[ ]'

Upper value of the kernel computation internal variable range that Simulink checks.

Simulink uses the maximum value to perform:

Note

The Kernel maximum parameter does not saturate or clip the actual kernel computation value signal.

#### Programmatic Use

 Block Parameter: KernelOutMax Type: character vector Values: '[ ]'| scalar Default: '[ ]'

## Tips

• If you are using a linear SVM model and it has many support vectors, then prediction can be slow. To efficiently predict responses based on a linear SVM model, remove the support vectors from the RegressionSVM object by using discardSupportVectors.

## Alternative Functionality

You can use a MATLAB Function block with the predict object function of the RegressionSVM object. For an example, see Predict Class Labels Using MATLAB Function Block.

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

• 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 predict function.

• 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.

## See Also

### Functions

Introduced in R2020b

Download ebook