RegressionSVM
R2026bSupport vector machine regression model
Description
RegressionSVM is a support vector machine (SVM) regression
model that stores data, parameter values, support vectors, and algorithmic
implementation information. Use a RegressionSVM model object to predict
values for new data (see predict) and compute the mean squared error
or epsilon-insensitive loss (see loss). You can also estimate resubstitution predictions (see resubPredict) and compute the resubstitution loss (see resubLoss).
Creation
Create a RegressionSVM object by using fitrsvm.
Properties
SVM Properties
This property is read-only.
Dual problem coefficients, returned as a vector of numeric values.
Alpha contains m elements, where
m is the number of support vectors in the trained SVM regression
model. The dual problem introduces two Lagrange multipliers for each support vector. The
values of Alpha are the differences between the two estimated
Lagrange multipliers for the support vectors. For more details, see Understanding Support Vector Machine Regression.
If you specified to remove duplicates using RemoveDuplicates,
then, for a particular set of duplicate observations that are support vectors,
Alpha contains one coefficient corresponding to the entire set.
That is, MATLAB® attributes a nonzero coefficient to one observation from the set of
duplicates and a coefficient of 0 to all other duplicate observations
in the set.
Data Types: single | double
This property is read-only.
Primal linear problem coefficients, returned as a numeric vector of length p, where p is the number of predictors in the SVM regression model.
The values in Beta are the linear coefficients for
the primal optimization problem.
If the model is obtained using a kernel function other than
'linear', this property is empty
('[]').
The predict function computes
predicted response values for the model as YFIT =
(X/S)×Beta + Bias, where S is the
value of the kernel scale stored in the
KernelParameters.Scale property.
Data Types: single | double
This property is read-only.
Bias term in the SVM regression model, returned as a scalar value.
Data Types: single | double
This property is read-only.
Box constraints for dual problem alpha coefficients, returned as a
numeric vector containing n elements, where
n is the number of observations in
X
(Mdl.NumObservations).
The absolute value of the dual coefficient Alpha
for observation i cannot exceed
BoxConstraints(i).
If you specify removing duplicates using RemoveDuplicates, then for a given set of duplicate
observations, MATLAB sums the box constraints, and then attributes the sum to
one observation and box constraints of 0 to all other
observations in the set.
Data Types: single | double
This property is read-only.
Caching information, returned as a structure with the following fields.
| Field | Description |
|---|---|
Size | Positive scalar value indicating the cache size (in
MB) that the software reserves to store entries of the
Gram matrix. Set the cache size by using the
CacheSize name-value argument in
fitrsvm. |
Algorithm | Character vector containing the name of the algorithm
used to remove entries from the cache when its capacity
is exceeded. Currently, the only available caching
algorithm is 'Queue'. You cannot set
the caching algorithm. |
Data Types: struct
This property is read-only.
Half the width of the epsilon-insensitive band, returned as a nonnegative scalar value.
Data Types: single | double
This property is read-only.
Gradient values in training data, returned as a numeric vector containing 2n elements, where n is the number of observations in the training data.
Element i of Gradient contains
the gradient value for the Alpha coefficient that
corresponds to the upper boundary of the epsilon-insensitive band at
observation i at the end of the optimization.
Element i + NumObservations of
Gradient contains the gradient value for the
Alpha coefficient that corresponds to the lower
boundary of the epsilon-insensitive band at observation
i at the end of the optimization.
Data Types: single | double
This property is read-only.
Flag indicating whether an observation is a support vector, returned
as an n-by-1 logical vector. n is
the number of observations in X (see
NumObservations). A value of
1 indicates that the corresponding observation in
the training data is a support vector.
If you specify removing duplicates using RemoveDuplicates, then for a given set of duplicate
observations that are support vectors,
IsSupportVector flags only one as a support
vector.
Data Types: logical
This property is read-only.
Kernel function parameters, returned as a structure with the following fields.
| Field | Description |
|---|---|
Function
| Kernel function name (a character vector). |
Scale | Numeric scale factor used to divide predictor values. |
You can specify values for
KernelParameters.Function and
KernelParameters.Scale by using the
KernelFunction and KernelScale
name-value arguments in fitrsvm,
respectively.
Data Types: struct
This property is read-only.
Parameter values used to train the SVM regression model, returned as a
model parameter object. Access the properties of
ModelParameters using dot notation. For example,
access the value of Epsilon used to train the model
as Mdl.ModelParameters.Epsilon.
This property is read-only.
Expected fraction of outliers in the training set, returned as a
scalar value in the range [0,1]. You can specify the expected fraction
of outliers using the OutlierFraction name-value
argument in fitrsvm.
Data Types: double
This property is read-only.
Name of the solver algorithm used to solve the optimization problem, returned as a value in this table.
| Value | Description |
|---|---|
'SMO' | Sequential Minimal Optimization |
'ISDA' | Iterative Single Data Algorithm |
'L1QP' | L1 soft-margin minimization by quadratic programming (requires an Optimization Toolbox™ license). |
This property is read-only.
Support vectors, returned as an m-by-p matrix of
numeric values. m is the number of support vectors
(sum(Mdl.IsSupportVector)), and p is the
number of predictors in X.
If you specified to remove duplicates using RemoveDuplicates,
then for a given set of duplicate observations that are support vectors,
SupportVectors contains one unique support vector.
Data Types: single | double
Convergence Control Properties
This property is read-only.
Convergence information, returned as a structure with the following fields.
| Field | Description |
|---|---|
Converged | Logical flag indicating whether the algorithm
converged. A value of 1 indicates
convergence. |
ReasonForConvergence | Character vector indicating the criterion the software used to detect convergence. |
Gap | Scalar feasibility gap between the dual and primal objective functions. |
GapTolerance | Scalar tolerance for the feasibility gap. You can set
this tolerance using the GapTolerance
name-value argument in fitrsvm. |
DeltaGradient | Scalar gradient difference between upper and lower violators. |
DeltaGradientTolerance | Scalar tolerance for the gradient difference. You can
set this tolerance using the
DeltaGradientTolerance name-value
argument in fitrsvm. |
LargestKKTViolation | Maximal scalar Karush-Kuhn-Tucker (KKT) violation value. |
KKTTolerance | Scalar tolerance for the largest KKT violation. You
can set this tolerance using the
KKTTolerance name-value argument
in fitrsvm. |
History | Structure containing convergence information recorded at periodic intervals during the model training process. This structure contains the following fields:
|
Objective | Numeric value of the dual objective. |
Data Types: struct
This property is read-only.
Number of iterations required for the optimization routine to reach convergence, returned as a positive integer value.
To set a limit on the number of iterations, use the
IterationLimit name-value argument of fitrsvm.
Data Types: single | double
This property is read-only.
Number of iterations between reductions of the active set during optimization, returned as a nonnegative integer value.
You can set the shrinkage period by using the
ShrinkagePeriod name-value argument in fitrsvm.
Data Types: single | double
Predictor Properties
This property is read-only.
Categorical predictor
indices, returned as a vector of positive integers. CategoricalPredictors
contains index values indicating that the corresponding predictors are categorical. The index
values are between 1 and p, where p is the number of
predictors used to train the model. If none of the predictors are categorical, then this
property is empty ([]).
Data Types: single | double
This property is read-only.
Expanded predictor names, returned as a cell array of character vectors.
If the model uses encoding for categorical variables, then
ExpandedPredictorNames includes the names that
describe the expanded variables. Otherwise,
ExpandedPredictorNames is the same as
PredictorNames.
Data Types: cell
This property is read-only.
Predictor names, returned as a cell array of character vectors
containing the name of each predictor in the order they appear in
X. PredictorNames has a length
equal to the number of columns in X.
Data Types: cell
This property is read-only.
Predictor means, returned as a vector of numeric values.
If the predictors are standardized, then Mu is a
numeric vector of length p, where
p is the number of predictors used to train the
model. In this case, the predict function centers
predictor matrix X by subtracting the corresponding
element of Mu from each column.
If the predictors are not standardized, then Mu is
empty ('[]').
If the data contains categorical predictors, then
Mu includes elements for the dummy variables for
those predictors. The corresponding entries in Mu are
0 because dummy variables are not centered or scaled.
Data Types: single | double
This property is read-only.
Predictor standard deviations, returned as a vector of numeric values.
If the predictors are standardized, then Sigma is a
numeric vector of length p, where
p is the number of predictors used to train the
model. In this case, the predict function scales the
predictor matrix X by dividing each column by the
corresponding element of Sigma, after centering each
element using Mu.
If the predictors are not standardized, then Sigma
is empty ('[]').
If the data contains categorical predictors, Sigma
includes elements for the dummy variables for those predictors. The
corresponding entries in Sigma are 1, because dummy
variables are not centered or scaled.
Data Types: single | double
This property is read-only.
Predictor values used to train the model, returned as a matrix of
numeric values if the model is trained on a matrix, or a table if the
model is trained on a table. X has size
n-by-p, where
n is the number of rows and p
is the number of predictor variables or columns in the training
data.
Data Types: single | double | table
Response Properties
This property is read-only.
Response variable name, returned as a character vector.
Data Types: char
Response transformation function, specified as "none" or a function handle.
ResponseTransform describes how the software transforms raw
response values.
For a MATLAB function or a function that you define, enter its function handle. For
example, you can enter Mdl.ResponseTransform =
@function, where
function accepts a numeric vector of the
original responses and returns a numeric vector of the same size containing the
transformed responses.
Data Types: char | string | function_handle
This property is read-only.
Observed response values, returned as a numeric vector containing
NumObservations number of elements.
Data Types: single | double
Other Data Properties
This property is read-only.
Cross-validation optimization of hyperparameters, returned as a SupervisedLearningBayesianOptimization object or a table of
hyperparameters and associated values. This property is nonempty if the
OptimizeHyperparameters name-value argument is nonempty when
you create the model. The value of
HyperparameterOptimizationResults depends on the setting of the
Optimizer option in the
HyperparameterOptimizationOptions value when you create the
model.
Value of Optimizer Option | Value of HyperparameterOptimizationResults |
|---|---|
"bayesopt" (default) | SupervisedLearningBayesianOptimization object |
"gridsearch" or "randomsearch" | Table of hyperparameters used, observed objective function values (cross-validation loss), and observation ranks from lowest (best) to highest (worst) |
This property is read-only.
Number of observations in the training data, returned as a positive integer value.
Data Types: single | double
This property is read-only.
Rows of the original training data stored in the model, returned as a
logical vector. This property is empty if all rows are stored in
X and Y.
Data Types: logical
This property is read-only.
Observation weights used to train the model, returned as a numeric
vector containing NumObservations number of elements.
fitrsvm normalizes the weights used for
training so that they sum to 1.
Data Types: single | double
Object Functions
compact | Reduce size of machine learning model |
crossval | Cross-validate machine learning model |
discardSupportVectors | Discard support vectors for linear support vector machine (SVM) regression model |
gather | Gather properties of Statistics and Machine Learning Toolbox object from GPU |
incrementalLearner | Convert support vector machine (SVM) regression model to incremental learner |
lime | Local interpretable model-agnostic explanations (LIME) |
loss | Regression error for support vector machine regression model |
partialDependence | Compute partial dependence |
plotPartialDependence | Create partial dependence plot (PDP) and individual conditional expectation (ICE) plots |
predict | Predict responses using support vector machine regression model |
resubLoss | Resubstitution regression loss |
resubPredict | Predict responses for training data using trained regression model |
resume | Resume training support vector machine regression model |
shapley | Shapley values |
Examples
Train a linear support vector machine (SVM) regression model using sample data stored in matrices.
Load the carsmall data set.
load carsmall rng(0,"twister") % For reproducibility
Specify Horsepower and Weight as the predictor variables (X) and MPG as the response variable (Y).
X = [Horsepower,Weight]; Y = MPG;
Train a linear SVM regression model.
Mdl = fitrsvm(X,Y)
Mdl =
RegressionSVM
ResponseName: 'Y'
CategoricalPredictors: []
ResponseTransform: 'none'
Alpha: [75×1 double]
Bias: 57.3800
KernelParameters: [1×1 struct]
NumObservations: 94
BoxConstraints: [94×1 double]
ConvergenceInfo: [1×1 struct]
IsSupportVector: [94×1 logical]
Solver: 'SMO'
Properties, Methods
Mdl is a trained RegressionSVM model.
Check the model for convergence.
Mdl.ConvergenceInfo.Converged
ans = logical
0
0 indicates that the model did not converge.
Train a linear SVM regression model with standardized predictors.
stdMdl = fitrsvm(X,Y,Standardize=true)
stdMdl =
RegressionSVM
ResponseName: 'Y'
CategoricalPredictors: []
ResponseTransform: 'none'
Alpha: [77×1 double]
Bias: 22.9131
KernelParameters: [1×1 struct]
Mu: [109.3441 2.9625e+03]
Sigma: [45.3545 805.9668]
NumObservations: 94
BoxConstraints: [94×1 double]
ConvergenceInfo: [1×1 struct]
IsSupportVector: [94×1 logical]
Solver: 'SMO'
Properties, Methods
Check the model for convergence.
stdMdl.ConvergenceInfo.Converged
ans = logical
1
1 indicates that the model did converge.
Compute the resubstitution mean squared error for the new model.
stdMSE = resubLoss(stdMdl)
stdMSE = 16.8551
References
[1] Nash, W.J., T. L. Sellers, S. R. Talbot, A. J. Cawthorn, and W. B. Ford. "The Population Biology of Abalone (Haliotis species) in Tasmania. I. Blacklip Abalone (H. rubra) from the North Coast and Islands of Bass Strait." Sea Fisheries Division, Technical Report No. 48, 1994.
[2] Waugh, S. "Extending and Benchmarking Cascade-Correlation: Extensions to the Cascade-Correlation Architecture and Benchmarking of Feed-forward Supervised Artificial Neural Networks." University of Tasmania Department of Computer Science thesis, 1995.
[3] Clark, D., Z. Schreter, A. Adams. "A Quantitative Comparison of Dystal and Backpropagation." submitted to the Australian Conference on Neural Networks, 1996.
[4] Lichman, M. UCI Machine Learning Repository, [http://archive.ics.uci.edu/ml]. Irvine, CA: University of California, School of Information and Computer Science.
Extended Capabilities
Usage notes and limitations:
To integrate the prediction of an SVM regression model into Simulink®, you can use the RegressionSVM Predict block in the Statistics and Machine Learning Toolbox™ library or a MATLAB Function block with the
predictfunction.When you train an SVM regression model by using
fitrsvm, the following restrictions apply.The value of the
ResponseTransformname-value argument cannot be an anonymous function. For fixed-point code generation, the value must be"none"(default).For fixed-point code generation, the value of the
KernelFunctionname-value argument must be"gaussian","linear", or"polynomial".Fixed-point code generation and code generation with a coder configurer do not support categorical predictors (
logical,categorical,char,string, orcell). You cannot use theCategoricalPredictorsname-value argument. To include categorical predictors in a model, preprocess them by usingdummyvarbefore fitting the model.
For more information, see Introduction to Code Generation for Statistics and Machine Learning Functions.
Refer to the usage notes and limitations in the C/C++ Code Generation section. The same usage notes and limitations apply to GPU code generation.
Usage notes and limitations:
The following object functions fully support GPU arrays:
The object functions execute on a GPU if at least one of the following applies:
The model was fitted with GPU arrays.
The predictor data that you pass to the object function is a GPU array.
The response data that you pass to the object function is a GPU array.
The
shapleyobject function partially supports GPU arrays. For more information, see GPU Arrays.
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2015bThe shapley
object function accepts GPU array input arguments when the machine learning model is
a RegressionSVM object with a linear kernel function, and the
shapley function uses an interventional algorithm
(Method="interventional").
If you perform Bayesian hyperparameter optimization by using a supervised learning fit
function, the optimization results are stored in a SupervisedLearningBayesianOptimization object. In previous releases, the
optimization results are stored in a BayesianOptimization object.
Starting in R2023b, training observations with missing predictor values are included in the X, Y, and W data properties. The RowsUsed property indicates the training observations stored in the model, rather than those used for training. Observations with missing predictor values continue to be omitted from the model training process.
In previous releases, the software omitted training observations that contained missing predictor values from the data properties of the model.
Starting in R2023a, you can fit a RegressionSVM object on a GPU by
using fitrsvm. Most
RegressionSVM object functions now support GPU array input
arguments so that they can execute on a GPU. The object functions that do not
support GPU array inputs are incrementalLearner, lime, and
shapley.
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)