Main Content


Predict resubstitution labels of discriminant analysis classification model



label = resubPredict(mdl) returns the labels that mdl predicts for the data mdl.X.

label is the predictions of mdl on the data that fitcdiscr used to create mdl.

[label,posterior] = resubPredict(mdl) returns the posterior class probabilities for the predictions.

[label,posterior,cost] = resubPredict(mdl) 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

Trained discriminant analysis classifier, specified as a ClassificationDiscriminant model object. To create a discriminant analysis classifier, use fitcdiscr.

Output Arguments

collapse all

Response that mdl predicts for the training data, returned as the same data type as the training response data mdl.Y. The predicted class labels are those with minimal expected misclassification cost. See Prediction Using Discriminant Analysis Models.

Posterior probabilities for classes that mdl predicts, returned as an N-by-K matrix. Here, N is the number of observations, and K is the number of classes.

Predicted misclassification costs, returned as an N-by-K matrix. Here, 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