主要内容

RegressionSVM

R2026b

Support 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

expand all

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.

FieldDescription
SizePositive 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.
AlgorithmCharacter 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.

FieldDescription
Function Kernel function name (a character vector).
ScaleNumeric 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.

ValueDescription
'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.

FieldDescription
ConvergedLogical flag indicating whether the algorithm converged. A value of 1 indicates convergence.
ReasonForConvergenceCharacter vector indicating the criterion the software used to detect convergence.
GapScalar feasibility gap between the dual and primal objective functions.
GapToleranceScalar tolerance for the feasibility gap. You can set this tolerance using the GapTolerance name-value argument in fitrsvm.
DeltaGradientScalar gradient difference between upper and lower violators.
DeltaGradientToleranceScalar tolerance for the gradient difference. You can set this tolerance using the DeltaGradientTolerance name-value argument in fitrsvm.
LargestKKTViolationMaximal scalar Karush-Kuhn-Tucker (KKT) violation value.
KKTToleranceScalar 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:

  • NumIterations — Array of iteration indices at which the software recorded convergence criteria.

  • GapGap values at these iterations.

  • DeltaGradientDeltaGradient values at these iterations.

  • LargestKKTViolationLargestKKTViolation values at these iterations.

  • NumSupportVectors — Number of support vectors at these iterations.

  • ObjectiveObjective values at these iterations.

ObjectiveNumeric 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 OptionValue 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

compactReduce size of machine learning model
crossvalCross-validate machine learning model
discardSupportVectorsDiscard support vectors for linear support vector machine (SVM) regression model
gatherGather properties of Statistics and Machine Learning Toolbox object from GPU
incrementalLearnerConvert support vector machine (SVM) regression model to incremental learner
limeLocal interpretable model-agnostic explanations (LIME)
lossRegression error for support vector machine regression model
partialDependenceCompute partial dependence
plotPartialDependenceCreate partial dependence plot (PDP) and individual conditional expectation (ICE) plots
predictPredict responses using support vector machine regression model
resubLossResubstitution regression loss
resubPredictPredict responses for training data using trained regression model
resumeResume training support vector machine regression model
shapleyShapley values

Examples

collapse all

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

expand all

Version History

Introduced in R2015b

expand all