Main Content

Creating Discriminant Analysis Model

The model for discriminant analysis is:

  • Each class (Y) generates data (X) using a multivariate normal distribution. In other words, the model assumesXhas 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.

Under this modeling assumption,fitcdiscrinfers the mean and covariance parameters of each class.

  • For linear discriminant analysis, it computes the sample mean of each class. Then it computes the sample covariance by first subtracting the sample mean of each class from the observations of that class, and taking the empirical covariance matrix of the result.

  • For quadratic discriminant analysis, it computes the sample mean of each class. Then it computes the sample covariances by first subtracting the sample mean of each class from the observations of that class, and taking the empirical covariance matrix of each class.

Thefitmethod does not use prior probabilities or costs for fitting.

Weighted Observations

fitcdiscrconstructs weighted classifiers using the following scheme. SupposeMis anN-by-Kclass membership matrix:

Mnk= 1 if observationnis from classk
Mnk= 0 otherwise.

The estimate of the class mean for unweighted data is

μ ^ k = n = 1 N M n k x n n = 1 N M n k .

For weighted data with positive weightswn, the natural generalization is

μ ^ k = n = 1 N M n k w n x n n = 1 N M n k w n .

The unbiased estimate of the pooled-in covariance matrix for unweighted data is

Σ ^ = n = 1 N k = 1 K M n k ( x n μ ^ k ) ( x n μ ^ k ) T N K .

For quadratic discriminant analysis,fitcdiscrusesK= 1.

For weighted data, assuming the weights sum to 1, the unbiased estimate of the pooled-in covariance matrix is

Σ ^ = n = 1 N k = 1 K M n k w n ( x n μ ^ k ) ( x n μ ^ k ) T 1 k = 1 K W k ( 2 ) W k ,

where

  • W k = n = 1 N M n k w n is the sum of the weights for classk.

  • W k ( 2 ) = n = 1 N M n k w n 2 is the sum of squared weights per class.

See Also

Functions

Objects

Related Topics