mdl = fitcdiscr(X, Y)
mdl = fitcdiscr(X, Y, Name, Value)
label = predict(mdl, Xnew)
[label, score, cost] = predict(mdl, Xnew)
fitcdiscr creates a ClassificationDiscriminant object from numeric predictors X and class labels Y.
Name-value arguments include ClassNames, Prior, DiscrimType, Gamma, and Delta. Supported discriminant types are linear, quadratic, diaglinear, and diagquadratic. Prediction returns posterior class scores.
X = [0 0; 0 1; 1 0; 1 1; 5 5; 5 6; 6 5; 6 6];
Y = [1; 1; 1; 1; 2; 2; 2; 2];
mdl = fitcdiscr(X, Y);
[label, score] = predict(mdl, [0.2 0.1; 5.2 5.1])
| Version | Description |
|---|---|
| 2.0.0 | initial version |