cvshrink
Class:ClassificationDiscriminant
Cross-validate regularization of linear discriminant
Syntax
err = cvshrink(obj)
[err,gamma] = cvshrink(obj)
[err,gamma,delta] = cvshrink(obj)
[err,gamma,delta,numpred] = cvshrink(obj)
[err,...] = cvshrink(obj,Name,Value)
Description
returns a vector of cross-validated classification error values for differing values of the regularization parameter Gamma.err
= cvshrink (obj
)
[
also returns the vector of Gamma values.err
,gamma
) = cvshrink (obj
)
[
also returns the vector of Delta values.err
,gamma
,delta
) = cvshrink (obj
)
[
returns the vector of number of nonzero predictors for each setting of the parameters Gamma and Delta.err
,gamma
,delta
,numpred
) = cvshrink (obj
)
[
cross validates with additional options specified by one or moreerr
,...] = cvshrink(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.
|
Default: |
|
Vector of Gamma values for cross-validation. Default: |
|
Number of Delta intervals for cross-validation. For every value of Gamma, Default: |
|
Number of Gamma intervals for cross-validation. Default: |
|
Verbosity level, an integer from Default: |
Output Arguments
|
Numeric vector or matrix of errors.
|
|
Vector of Gamma values used for regularization. SeeGamma and Delta. |
|
Vector or matrix of Delta values used for regularization. SeeGamma and Delta.
|
|
Numeric vector or matrix containing the number of predictors in the model at various regularizations.
|
Examples
More About
Tips
Examine the
err
andnumpred
outputs to see the tradeoff between cross-validated error and number of predictors. When you find a satisfactory point, set the correspondinggamma
anddelta
properties in the model using dot notation. For example, if(i,j)
is the location of the satisfactory point, setobj.Gamma = gamma(i); obj.Delta = delta(i,j);