# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

# ClassificationDiscriminant.template

Discriminant analysis classifier template for ensemble (to be removed)

ClassificationDiscriminant.template will be removed in a future release. Use templateDiscriminant instead.

## Syntax

t = ClassificationDiscriminant.template()
t = ClassificationDiscriminant.template(Name,Value)

## Description

t = ClassificationDiscriminant.template() returns a learner template suitable to use in the fitensemble function.

t = ClassificationDiscriminant.template(Name,Value) creates a template with additional options specified by one or more Name,Value pair arguments.

## Input Arguments

expand all

### 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 single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

expand all

Linear coefficient threshold, specified as the comma-separated pair consisting of 'Delta' and a nonnegative scalar value. If a coefficient of Mdl has magnitude smaller than Delta, Mdl sets this coefficient to 0, and you can eliminate the corresponding predictor from the model. Set Delta to a higher value to eliminate more predictors.

Delta must be 0 for quadratic discriminant models.

Data Types: single | double

Discriminant type, specified as the comma-separated pair consisting of 'DiscrimType' and a character vector in this table.

ValueDescriptionPredictor Covariance Treatment
'linear'Regularized linear discriminant analysis (LDA)
• All classes have the same covariance matrix.

• ${\stackrel{^}{\Sigma }}_{\gamma }=\left(1-\gamma \right)\stackrel{^}{\Sigma }+\gamma \text{diag}\left(\stackrel{^}{\Sigma }\right).$

$\stackrel{^}{\Sigma }$ is the empirical, pooled covariance matrix and γ is the amount of regularization.

'diaglinear'LDAAll classes have the same, diagonal covariance matrix.
'pseudolinear'LDAAll classes have the same covariance matrix. The software inverts the covariance matrix using the pseudo inverse.
'diagquadratic'QDAThe covariance matrices are diagonal and can vary among classes.
'pseudoquadratic'QDAThe covariance matrices can vary among classes. The software inverts the covariance matrix using the pseudo inverse.

 Note:   To use regularization, you must specify 'linear'. To specify the amount of regularization, use the Gamma name-value pair argument.

Coeffs property flag, specified as the comma-separated pair consisting of 'FillCoeffs' and 'on' or 'off'. Setting the flag to 'on' populates the Coeffs property in the classifier object. This can be computationally intensive, especially when cross validating. The default is 'on', unless you specify a cross validation name-value pair, in which case the flag is set to 'off' by default.

Example: 'FillCoeffs','off'

Amount of regularization to apply when estimating the covariance matrix of the predictors, specified as the comma-separated pair consisting of 'Gamma' and a scalar value in the interval [0,1]. Gamma provides finer control over the covariance matrix structure than DiscrimType.

• If you specify 0, then the software does not use regularization to adjust the covariance matrix. That is, the software estimates and uses the unrestricted, empirical covariance matrix.

• For linear discriminant analysis, if the empirical covariance matrix is singular, then the software automatically applies the minimal regularization required to invert the covariance matrix. You can display the chosen regularization amount by entering Mdl.Gamma at the command line.

• For quadratic discriminant analysis, if at least one class has an empirical covariance matrix that is singular, then the software throws an error.

• If you specify a value in the interval (0,1), then you must implement linear discriminant analysis, otherwise the software throws an error. Consequently, the software sets DiscrimType to 'linear'.

• If you specify 1, then the software uses maximum regularization for covariance matrix estimation. That is, the software restricts the covariance matrix to be diagonal. Alternatively, you can set DiscrimType to 'diagLinear' or 'diagQuadratic' for diagonal covariance matrices.

Example: 'Gamma',1

Data Types: single | double

Flag to save covariance matrix, specified as the comma-separated pair consisting of 'SaveMemory' and either 'on' or 'off'. If you specify 'on', then fitcdiscr does not store the full covariance matrix, but instead stores enough information to compute the matrix. The predict method computes the full covariance matrix for prediction, and does not store the matrix. If you specify 'off', then fitcdiscr computes and stores the full covariance matrix in Mdl.

Specify SaveMemory as 'on' when the input matrix contains thousands of predictors.

Example: 'SaveMemory','on'

## Output Arguments

expand all

Discriminant analysis classification template suitable to use in the fitensemble function, returned as a classification template object. In an ensemble, t specifies how to create the discriminant analysis classifier.

## Examples

expand all

Create a nondefault discriminant analysis template for use in fitensemble.

Create a template for pseudolinear discriminant analysis.

t = ClassificationDiscriminant.template('discrimType','pseudoLinear')
t =

Fit template for classification Discriminant.

DiscrimType: 'pseudoLinear'
Gamma: []
Delta: []
FillCoeffs: []
SaveMemory: []
Method: 'Discriminant'
Type: 'classification'

You can use t for ensemble learning.