crossval
Class:ClassificationDiscriminant
Cross-validated discriminant analysis classifier
Syntax
cvmodel= crossval(obj)
cvmodel= crossval(obj,Name,Value)
Description
creates a partitioned model fromcvmodel
= crossval(obj
)obj
, a fitted discriminant analysis classifier. By default,crossval
uses 10-fold cross validation on the training data to createcvmodel
.
creates a partitioned model with additional options specified by one or morecvmodel
= crossval(obj
,Name,Value
)Name,Value
pair arguments.
Input Arguments
|
Discriminant analysis classifier, produced using |
Name-Value Arguments
Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN
, whereName
is the argument name andValue
is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.
Before R2021a, use commas to separate each name and value, and encloseName
in quotes.
|
Object of class Use only one of these options at a time: Default: |
|
Holdout validation tests the specified fraction of the data, and uses the rest of the data for training. Specify a numeric scalar from |
|
Number of folds to use in a cross-validated classifier, a positive integer value greater than 1. Use only one of these options at a time: Default:10 |
|
Set to Use only one of these options at a time: |
Examples
Create a classification model for the Fisher iris data, and then create a cross-validation model. Evaluate the quality the model usingkfoldLoss
.
load fisheriris obj = fitcdiscr(meas,species); cvmodel = crossval(obj); L = kfoldLoss(cvmodel) L = 0.0200
Tips
Assess the predictive performance of
obj
on cross-validated data using the “kfold” methods and properties ofcvmodel
, such askfoldLoss
.
Alternatives
You can create a cross-validation classifier directly from the data, instead of creating a discriminant analysis classifier followed by a cross-validation classifier. To do so, include one of these options infitcdiscr
:'CrossVal'
,'CVPartition'
,'Holdout'
,'KFold'
, or'Leaveout'
.