Discriminant Analysis Classification

Discriminant analysis is a classification method. It assumes that different classes generate data based on different Gaussian distributions.

  • To train (create) a classifier, the fitting function estimates the parameters of a Gaussian distribution for each class.

  • To predict the classes of new data, the trained classifier finds the class with the smallest misclassification cost .

Linear discriminant analysis is also known as the Fisher discriminant, named for its inventor, Sir R. A. Fisher [1].

Create Discriminant Analysis Classifiers

This example shows how to train a basic discriminant analysis classifier to classify irises in Fisher's iris data.

Load the data.

load fisheriris

Create a default (linear) discriminant analysis classifier.

MdlLinear = fitcdiscr(meas,species);

To visualize the classification boundaries of a 2-D linear classification of the data.

Classify an iris with average measurements.

meanmeas = mean(meas);
meanclass = predict(MdlLinear,meanmeas)
meanclass = 1x1 cell array
    {'versicolor'}

Create a quadratic classifier.

MdlQuadratic = fitcdiscr(meas,species,'DiscrimType','quadratic');

To visualize the classification boundaries of a 2-D quadratic classification of the data.

Classify an iris with average measurements using the quadratic classifier.

meanclass2 = predict(MdlQuadratic,meanmeas)
meanclass2 = 1x1 cell array
    {'versicolor'}