Main Content


Classify observations in discriminant analysis classifier by resubstitution



label = resubPredict(Mdl) returns a vector of predicted class labels for the trained discriminant analysis classifier Mdl using the predictor data stored in Mdl.X. label has the same data type as the training response data Mdl.Y, and the same number of entries as the number of rows in Mdl.X.

[label,posterior] = resubPredict(Mdl,___) also returns the posterior class probabilities for the predictors.

[label,posterior,cost] = resubPredict(Mdl) also returns the predicted misclassification costs per class for the resubstituted data.


collapse all

Find the total number of misclassifications of the Fisher iris data for a discriminant analysis classifier.

Create a classification model for the Fisher iris data.

load fisheriris
Mdl = fitcdiscr(meas,species);

Predict resubstitution labels of the model.

Ypredict = resubPredict(Mdl);

Find the total number of different misclassifications.

Ysame = strcmp(Ypredict,species); % true when ==
sum(~Ysame) % how many are different?
ans =

Input Arguments

collapse all

Discriminant analysis classifier, specified as a ClassificationDiscriminant model object trained with fitcdiscr.

Output Arguments

collapse all

Predicted class labels, returned as a categorical or character array, logical or numeric vector, or cell array of character vectors.

label has the same data type as Mdl.ClassNames and the same number of rows as Mdl.X. The predicted class labels are those with minimal expected misclassification cost. See Prediction Using Discriminant Analysis Models.

Posterior probabilities for classes predicted by Mdl, returned as an N-by-K matrix. N is the number of observations, and K is the number of classes.

Predicted misclassification costs, returned as an N-by-K matrix. N is the number of observations, and K is the number of classes. Each cost is the average misclassification cost with respect to the posterior probability.

More About

collapse all

Posterior Probability

posterior(i,k) is the posterior probability of class k for observation i. For the mathematical definition, see Posterior Probability.

Version History

Introduced in R2011b

expand all