Main Content

RegressionPartitionedSVM

Namespace: classreg.learning.partition
Superclasses: RegressionPartitionedModel

Cross-validated support vector machine regression model

Description

RegressionPartitionedSVM is a set of support vector machine (SVM) regression models trained on cross-validated folds.

Construction

CVMdl = crossval(mdl) returns a cross-validated (partitioned) support vector machine regression model, CVMdl, from a trained SVM regression model, mdl.

CVMdl = crossval(mdl,Name,Value) returns a cross-validated model with additional options specified by one or more Name,Value pair arguments. Name can also be a property name and Value is the corresponding value. Name must appear inside single quotes (''). You can specify several name-value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Input Arguments

expand all

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

Properties

expand all

This property is read-only.

Categorical predictor indices, specified 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

Name of the cross-validated model, stored as a character vector.

Data Types: char

Number of cross-validation folds, stored as a positive integer value.

Data Types: single | double

Cross-validation parameters, stored as an object.

Number of observations in the training data, stored as a positive integer value.

Data Types: single | double

Data partition for cross-validation, stored as a cvpartition object.

Predictor names, stored as a cell array of character vectors containing the name of each predictor in the order in which they appear in X. PredictorNames has a length equal to the number of columns in X.

Data Types: cell

Response variable name, stored 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 | function_handle

Trained, compact regression models, stored as a cell array of CompactRegressionSVM models.

Data Types: cell

Observation weights used to train the model, stored as a numeric vector containing NumObservation number of elements. fitrsvm normalizes the weights used for training so that they sum to 1.

Data Types: single | double

Predictor values used to train the model, stored 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

Observed responses used to cross-validate the model, specified as a numeric vector containing NumObservations elements.

Each row of Y represents the observed classification of the corresponding row of X.

Data Types: single | double

Object Functions

gatherGather properties of Statistics and Machine Learning Toolbox object from GPU
kfoldLossLoss for cross-validated partitioned regression model
kfoldPredictPredict responses for observations in cross-validated regression model
kfoldfunCross-validate function for regression

Examples

collapse all

This example shows how to train a cross-validated SVM regression model using crossval.

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, using a Gaussian kernel function with a kernel scale equal to 2.2. Standardize the data.

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

mdl is a trained RegressionSVM regression model.

Cross validate the model using 10-fold cross validation.

CVMdl = crossval(mdl)
CVMdl = 

  classreg.learning.partition.RegressionPartitionedSVM
      CrossValidatedModel: 'SVM'
           PredictorNames: {1x8 cell}
    CategoricalPredictors: 1
             ResponseName: 'Var9'
          NumObservations: 4177
                    KFold: 10
                Partition: [1x1 cvpartition]
        ResponseTransform: 'none'


  Properties, Methods

CVMdl is a RegressionPartitionedSVM cross-validated regression model. The software:

1. Randomly partitions the data into ten equally-sized sets.

2. Trains an SVM regression model on nine of the ten sets.

3. Repeats steps 1 and 2 k = 10 times. It leaves out one of the partitions each time, and trains on the other nine partitions.

4. Combines generalization statistics for each fold.

Display the first of the 10 trained models.

FirstModel = CVMdl.Trained{1}
FirstModel = 

  classreg.learning.regr.CompactRegressionSVM
       PredictorNames: {1x8 cell}
         ResponseName: 'Var9'
    ResponseTransform: 'none'
                Alpha: [3553x1 double]
                 Bias: 11.0623
     KernelParameters: [1x1 struct]
                   Mu: [0 0 0 0.5242 0.4080 0.1393 0.8300 0.3599 0.1811 0.2392]
                Sigma: [1 1 1 0.1205 0.0995 0.0392 0.4907 0.2217 0.1103 0.1392]
       SupportVectors: [3553x10 double]


  Properties, Methods

FirstModel is the first of the 10 trained CompactRegressionSVM models.

This example shows how to specify a holdout proportion for training a cross-validated SVM regression model.

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, using a Gaussian kernel function with a kernel scale equal to 2.2. Standardize the data.

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

mdl is a trained RegressionSVM regression model.

Cross validate the regression model by specifying a 10% holdout sample.

CVMdl = crossval(mdl,'Holdout',0.1)
CVMdl = 

  classreg.learning.partition.RegressionPartitionedSVM
      CrossValidatedModel: 'SVM'
           PredictorNames: {1x8 cell}
    CategoricalPredictors: 1
             ResponseName: 'Var9'
          NumObservations: 4177
                    KFold: 1
                Partition: [1x1 cvpartition]
        ResponseTransform: 'none'


  Properties, Methods

CVMdl is a RegressionPartitionedSVM model object.

Extract and display the trained, compact SVM regression model from CVMdl.

CVMdl.Trained{1}
TrainedModel = 

  classreg.learning.regr.CompactRegressionSVM
       PredictorNames: {1x8 cell}
         ResponseName: 'Var9'
    ResponseTransform: 'none'
                Alpha: [3530x1 double]
                 Bias: 11.2646
     KernelParameters: [1x1 struct]
                   Mu: [0 0 0 0.5244 0.4080 0.1393 0.8282 0.3595 0.1805 0.2386]
                Sigma: [1 1 1 0.1198 0.0989 0.0388 0.4891 0.2218 0.1093 0.1390]
       SupportVectors: [3530x10 double]


  Properties, Methods

TrainedModel is a CompactRegressionSVM regression model that was trained using 90% of the data.

Alternatives

You can create a RegressionPartitionedSVM model using the following techniques:

  • Use the training function fitrsvm and specify one of the 'CrossVal', 'Holdout', 'KFold', or 'Leaveout' name-value pairs.

  • Train a model using fitrsvm, then cross validate the model using the crossval method.

  • Create a cross validation partition using cvpartition, then pass the resulting partition object to fitrsvm during training using the 'CVPartition' name-value pair.

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