Main Content

resubPredict

Class: RegressionSVM

Predict resubstitution response of support vector machine regression model

Description

example

yfit = resubPredict(mdl) returns a vector of predicted response values, yfit, for the trained support vector machine (SVM) regression model mdl using the predictor data stored in mdl.X.

yfit = resubPredict(mdl,PredictionForMissingValue=prediction) uses the prediction value as the predicted response for observations with missing values in the predictor data mdl.X. By default, resubPredict uses the median of the observed response values in the training data. (since R2023b)

Input Arguments

expand all

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

Since R2023b

Predicted response value to use for observations with missing predictor values, specified as "median", "mean", or a numeric scalar.

ValueDescription
"median"resubPredict uses the median of the observed response values in the training data as the predicted response value for observations with missing predictor values.
"mean"resubPredict uses the mean of the observed response values in the training data as the predicted response value for observations with missing predictor values.
Numeric scalarresubPredict uses this value as the predicted response value for observations with missing predictor values.

Example: "mean"

Example: NaN

Data Types: single | double | char | string

Output Arguments

expand all

Predicted responses, returned as a vector of numeric values. The length of yfit is equal to the number of observations in the training data, mdl.NumObservations.

For details about how to predict responses, see Equation 1 and Equation 2 in Understanding Support Vector Machine Regression.

Examples

expand all

This example shows how to train an SVM regression model, then use the model to generate predicted response values from the training data.

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);

Use the trained model to predict response values based on the original data.

yfit = resubPredict(mdl);

Display the first ten predicted responses alongside the actual response values.

[mdl.Y(1:10),yfit(1:10)]
ans =

   15.0000    8.1836
    7.0000    8.3545
    9.0000   10.9383
   10.0000    9.3446
    7.0000    6.4042
    8.0000    7.7910
   20.0000   13.8275
   16.0000   11.7959
    9.0000    9.5724
   19.0000   13.6909

The left column shows the actual response and the right column shows the corresponding predicted response.

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

Version History

Introduced in R2015b

expand all