Function
1. NaiveBayes.predict(_)
2. NaiveBayes.find(_)
Description
1. Returns the estimated labels of one or multiple test instances and the accuracy of the estimates.
2. Returns the labels with their respective probabilities in descending order.
Examples using Iris Data Set
load fisheriris
X = meas;
Y = species;
Xnew = [min(X);mean(X);max(X)];
mdl = NaiveBayes('gaussian');
mdl = mdl.fit(X,Y)
Ypred = mdl.predict(Xnew)
Ypred =
'setosa'
'versicolor'
'virginica'
Ynew = {'versicolor';'versicolor';'virginica'};
accuracy = accuracy_score(Ypred,Ynew)
accuracy =
0.6667
See more examples described in the script files.
David Ferreira (2021). Naive Bayes (NB) Classifier (https://github.com/ferreirad08/NaiveBayesClassifier/releases/tag/1.1.7), GitHub. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.