Compact discriminant analysis class
A CompactClassificationDiscriminant
object
is a compact version of a discriminant analysis classifier. The compact
version does not include the data for training the classifier. Therefore,
you cannot perform some tasks with a compact classifier, such as cross
validation. Use a compact classifier for making predictions (classifications)
of new data.
constructs a compact
classifier from a full classifier.cobj
=
compact(obj
)
constructs
a compact discriminant analysis classifier from the class means cobj
= makecdiscr(Mu
,Sigma
)Mu
and
covariance matrix Sigma
. For syntax details, see makecdiscr
.

Discriminant analysis classifier, created using 



List of categorical predictors, which is always empty ( 

List of the elements in the training data 

The equation of the boundary between class
where If 

Square matrix, where Change a 

Value of the Delta threshold for a linear discriminant model,
a nonnegative scalar. If a coefficient of
Change 

Row vector of length equal to the number of predictors in If 

String specifying the discriminant type. One of:
Change You can change between linear types, or between quadratic types, but cannot change between linear and quadratic types. 

Value of the Gamma regularization parameter, a scalar from


Logarithm of the determinant of the withinclass covariance
matrix. The type of


Nonnegative scalar, the minimal value of the Gamma parameter
so that the correlation matrix is invertible. If the correlation matrix
is not singular, 

Class means, specified as a 

Cell array of names for the predictor variables, in the order
in which they appear in the training data 

Numeric vector of prior probabilities for each class. The order
of the elements of Add or change a 

String describing the response variable 

Function handle for transforming scores, or string representing
a builtin transformation function. Implement dot notation to add or change a


Withinclass covariance matrix or matrices. The dimensions depend
on

compareHoldout  Compare accuracies of two classification models using new data 
edge  Classification edge 
logP  Log unconditional probability density for discriminant analysis classifier 
loss  Classification error 
mahal  Mahalanobis distance to class means 
margin  Classification margins 
nLinearCoeffs  Number of nonzero linear coefficients 
predict  Predict classification 
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(kx\right)C\left(yk\right)},$$
where
$$\widehat{y}$$ is the predicted classification.
K is the number of classes.
$$\widehat{P}\left(kx\right)$$ is the posterior probability of class k for observation x.
$$C\left(yk\right)$$ is the cost of classifying an observation as y when its true class is k.
For details, see How the predict Method Classifies.
Regularization is the process of finding a small set of predictors
that yield an effective predictive model. For linear discriminant
analysis, there are two parameters, γ and δ,
that control regularization as follows. cvshrink
helps
you select appropriate values of the parameters.
Let Σ represent the covariance matrix of the data X, and let $$\widehat{X}$$ be the centered data (the data X minus the mean by class). Define
$$D=\text{diag}\left({\widehat{X}}^{T}*\widehat{X}\right).$$
The regularized covariance matrix $$\tilde{\Sigma}$$ is
$$\tilde{\Sigma}=\left(1\gamma \right)\Sigma +\gamma D.$$
Whenever γ ≥ MinGamma
, $$\tilde{\Sigma}$$ is nonsingular.
Let μ_{k} be the mean vector for those elements of X in class k, and let μ_{0} be the global mean vector (the mean of the rows of X). Let C be the correlation matrix of the data X, and let $$\tilde{C}$$ be the regularized correlation matrix:
$$\tilde{C}=\left(1\gamma \right)C+\gamma I,$$
where I is the identity matrix.
The linear term in the regularized discriminant analysis classifier for a data point x is
$${\left(x{\mu}_{0}\right)}^{T}{\tilde{\Sigma}}^{1}\left({\mu}_{k}{\mu}_{0}\right)=\left[{\left(x{\mu}_{0}\right)}^{T}{D}^{1/2}\right]\left[{\tilde{C}}^{1}{D}^{1/2}\left({\mu}_{k}{\mu}_{0}\right)\right].$$
The parameter δ enters into this equation as a threshold on the final term in square brackets. Each component of the vector $$\left[{\tilde{C}}^{1}{D}^{1/2}\left({\mu}_{k}{\mu}_{0}\right)\right]$$ is set to zero if it is smaller in magnitude than the threshold δ. Therefore, for class k, if component j is thresholded to zero, component j of x does not enter into the evaluation of the posterior probability.
The DeltaPredictor
property is a vector related
to this threshold. When δ ≥ DeltaPredictor(i)
, all classes k have
$$\left{\tilde{C}}^{1}{D}^{1/2}\left({\mu}_{k}{\mu}_{0}\right)\right\le \delta .$$
Therefore, when δ ≥ DeltaPredictor(i)
, the regularized
classifier does not use predictor i
.
Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB^{®} documentation.