mdl = fitcnb(X, Y)
mdl = fitcnb(X, Y, Name, Value)
label = predict(mdl, Xnew)
[label, score, cost] = predict(mdl, Xnew)
fitcnb creates a ClassificationNaiveBayes object from numeric predictors X and class labels Y.
The current implementation fits normal predictor distributions. Name-value arguments include ClassNames, Prior, DistributionNames, and Weights. Prediction returns posterior class scores.
X = [0 0; 0 1; 1 0; 5 5; 5 6; 6 5];
Y = [1; 1; 1; 2; 2; 2];
mdl = fitcnb(X, Y);
[label, score] = predict(mdl, [0.2 0.1; 5.2 5.1])
| Version | Description |
|---|---|
| 2.0.0 | initial version |