resubLoss

Class: RegressionSVM

Resubstitution loss for support vector machine regression model

Syntax

L = resubLoss(mdl)
L = resubLoss(mdl,Name,Value)

Description

L = resubLoss(mdl) returns the resubstitution loss for the support vector machine (SVM) regression model mdl, using the training data stored in mdl.X and corresponding response values stored in mdl.Y.

L = resubLoss(mdl,Name,Value) returns the resubstitution loss with additional options specified by one or more Name,Value pair arguments. For example, you can specify the loss function or observation weights.

Input Arguments

expand all

Full, trained SVM regression model, specified as a RegressionSVM model returned by fitrsvm.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Loss function, specified as the comma-separated pair consisting of 'LossFun' and 'mse', 'epsiloninsensitive', or a function handle.

  • The following table lists the available loss functions. Specify one using its corresponding value.

    ValueLoss Function
    'mse'Mean Squared Error
    'epsiloninsensitive'Epsilon-Insensitive Loss Function
  • Specify your own function using function handle notation.

    Suppose that n = size(X,1) is the sample size. Your function must have the signature lossvalue = lossfun(Y,Yfit,W), where:

    • The output argument lossvalue is a numeric value.

    • You choose the function name (lossfun).

    • Y is an n-by-1 numeric vector of observed response values.

    • Yfit is an n-by-1 numeric vector of predicted response values, calculated using the corresponding predictor values in X (similar to the output of predict).

    • W is an n-by-1 numeric vector of observation weights.

    Specify your function using 'LossFun',@lossfun.

Example: 'LossFun','epsiloninsensitive'

Data Types: char | string | function_handle

Observation weights, specified as the comma-separated pair consisting of 'Weights' and a numeric vector. Weights must be the same length as the number of rows in X. The software weighs the observations in each row of X using the corresponding weight value in Weights.

Data Types: single | double

Output Arguments

expand all

Resubstitution loss, returned as a scalar value.

The resubstitution loss is the loss calculated between the response training data and the model’s predicted response values based on the input training data.

Resubstitution loss can be an overly optimistic estimate of the predictive error on new data. If the resubstitution loss is high, the model’s predictions are not likely to be very good. However, having a low resubstitution loss does not guarantee good predictions for new data.

To better assess the predictive accuracy of your model, cross validate the model using crossval.

Examples

expand all

This example shows how to train an SVM regression model, then calculate the resubstitution loss using mean square error (MSE) and epsilon-insensitive loss.

This example uses the abalone data from the UCI Machine Learning Repository. Download the data and save it in your current directory with the name 'abalone.data'.

Read the data into a table.

tbl = readtable('abalone.data','Filetype','text','ReadVariableNames',false);
rng default  % for reproducibility

The sample data contains 4177 observations. All of the predictor variables are continuous except for sex, which is a categorical variable with possible values 'M' (for males), 'F' (for females), and 'I' (for infants). The goal is to predict the number of rings on the abalone, and thereby determine its age, using physical measurements.

Train an SVM regression model to the data, using a Gaussian kernel function with an automatic kernel scale. Standardize the data.

mdl = fitrsvm(tbl,'Var9','KernelFunction','gaussian','KernelScale','auto','Standardize',true);

Calculate the resubstitution loss using mean square error (MSE).

mse_loss = resubLoss(mdl)
mse_loss =

    4.0603

Calculate the epsilon-insensitive loss.

eps_loss = resubLoss(mdl,'LossFun','epsiloninsensitive')
eps_loss =

    1.1027

More About

expand all

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, Ph.D. thesis, Computer Science Department, University of Tasmania, 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.

Introduced in R2015b