Categories &

Functions List

Class Definition: CompactRegressionSVM

statistics: CompactRegressionSVM

Create a CompactRegressionSVM object, a support vector regression model that has dropped its training data.

obj = CompactRegressionSVM (Mdl) returns the compact form of the RegressionSVM object Mdl. It is normally reached through compact (Mdl) rather than called directly.

The compact model keeps what is needed to answer about new data, the support vectors and their coefficients, the intercept, the kernel, the standardization and the response transform, and drops what only describes the fit: the predictor and response data, the observation weights, the rows used, the observation count, and which training rows became support vectors. predict and loss therefore agree with the full model to the last digit, while resubPredict and resubLoss do not exist here, there being no training data left to resubstitute.

See also: RegressionSVM, fitrsvm

Source Code: CompactRegressionSVM

The CompactRegressionSVM class contains the following properties:

A positive integer scalar. This property is read-only.

A cell array of character vectors. This property is read-only.

A character vector. This property is read-only.

A non-negative scalar, carried over from the model this one was compacted from. It is what the 'epsiloninsensitive' loss charges against. This property is read-only.

A row vector with one entry per predictor, used for standardization. Empty when the predictor data were not standardized. This property is read-only.

A row vector with one entry per predictor, used for standardization. Empty when the predictor data were not standardized. This property is read-only.

A numeric column vector with one entry per support vector, signed, as in the model this one was compacted from. This property is read-only.

A numeric column vector, equal to obj.SupportVectors' * obj.Alpha, and empty for any kernel other than linear. This property is read-only.

A numeric scalar. With a linear kernel the prediction is X * obj.Beta + obj.Bias. This property is read-only.

A numeric matrix with one row per support vector, on the scale the model was trained on. This property is read-only.

A structure with fields Function and Scale, and Order for a polynomial kernel. Function names the kernel as MATLAB names it, so a radial basis kernel reports 'gaussian' whichever spelling was given. This property is read-only.

A numeric vector of column indices, and empty when none is. This property is read-only.

A cell array of character vectors. This property is read-only.

A function handle, applied by predict to the model’s output. It may be set after construction, either to a handle or to the name of a supported transformation.

The CompactRegressionSVM class offers the following public methods:

CompactRegressionSVM: obj = discardSupportVectors (obj)

obj = discardSupportVectors (obj) empties Alpha and SupportVectors, leaving Beta and Bias to decide every prediction. A linear kernel needs nothing else, so the returned model predicts what it predicted before while carrying one vector in place of many.

The kernel must be linear. Under any other the support vectors are part of the decision function and cannot be dropped. Discarding twice is not an error and changes nothing.

See also: fitrsvm, RegressionSVM, CompactRegressionSVM

CompactRegressionSVM: yFit = predict (obj, XC)

yFit = predict (obj, XC) returns a column vector holding the predicted response for each row of XC. It agrees with the full model this object was compacted from.

  • obj must be a CompactRegressionSVM class object.
  • XC must be a numeric matrix with the same number of predictors as the data the model was trained on.

See also: CompactRegressionSVM, RegressionSVM

CompactRegressionSVM: L = loss (obj, X, Y)
CompactRegressionSVM: L = loss (…, name, value)

L = loss (obj, X, Y) returns the weighted mean squared error between the response Y and the response the model predicts for X.

  • obj must be a CompactRegressionSVM class object.
  • X must be a numeric matrix with the same number of predictors as the data the model was trained on.
  • Y must be a numeric vector with as many rows as X.

L = loss (…, name, value) accepts the following Name-Value pairs.

NameValue
'LossFun''mse', the default, 'epsiloninsensitive', or a function handle called as lossfun (Y, yFit, W) returning a scalar.
'Weights'A numeric vector of observation weights with one entry per row of X. It defaults to a uniform weight. The weights are normalized to sum to one before the loss is formed.

See also: CompactRegressionSVM, RegressionSVM

CompactRegressionSVM: savemodel (obj, filename)

savemodel (obj, filename) saves every property of the CompactRegressionSVM object obj into filename in binary format, so that it can be read back with loadmodel.

See also: loadmodel, CompactRegressionSVM