**Class: **ClassificationDiscriminant

Fit discriminant analysis classifier (to be removed)

`ClassificationDiscriminant.fit`

will be removed
in a future release. Use `fitcdiscr`

instead.

`obj = ClassificationDiscriminant.fit(x,y)`

obj = ClassificationDiscriminant.fit(x,y,Name,Value)

returns
a discriminant analysis classifier based on the input variables (also
known as predictors, features, or attributes) `obj`

= ClassificationDiscriminant.fit(`x`

,`y`

)`x`

and
output (response) `y`

.

fits
a classifier with additional options specified by one or more `obj`

= ClassificationDiscriminant.fit(`x`

,`y`

,`Name,Value`

)`Name,Value`

pair
arguments. If you use one of the following five options, `obj`

is
of class `ClassificationPartitionedModel`

: `'CrossVal'`

, `'KFold'`

, `'Holdout'`

, `'Leaveout'`

,
or `'CVPartition'`

. Otherwise, `obj`

is
of class `ClassificationDiscriminant`

.

The model for discriminant analysis is:

Each class (

`Y`

) generates data (`X`

) using a multivariate normal distribution. That is, the model assumes`X`

has a Gaussian mixture distribution (`gmdistribution`

).For linear discriminant analysis, the model has the same covariance matrix for each class, only the means vary.

For quadratic discriminant analysis, both means and covariances of each class vary.

`predict`

classifies so as to minimize the expected
classification cost:

$$\widehat{y}=\underset{y=1,\mathrm{...},K}{\mathrm{arg}\mathrm{min}}{\displaystyle \sum _{k=1}^{K}\widehat{P}\left(k|x\right)C\left(y|k\right)},$$

where

$$\widehat{y}$$ is the predicted classification.

*K*is the number of classes.$$\widehat{P}\left(k|x\right)$$ is the posterior probability of class

*k*for observation*x*.$$C\left(y|k\right)$$ is the cost of classifying an observation as

*y*when its true class is*k*.

For details, see How the predict Method Classifies.

The `classify`

function also
performs discriminant analysis. `classify`

is usually
more awkward to use:

`classify`

requires you to fit the classifier every time you make a new prediction.`classify`

does not perform cross validation.`classify`

requires you to fit the classifier when changing prior probabilities.

Was this topic helpful?