How to detection score using Naive Bayes classifier?
1 次查看(过去 30 天)
显示 更早的评论
Hi, I am new in Naive Bayes classifier. How to get detection score or test score using Naive Bayes classifier in Matlab? Is posterior probability=detection score?
0 个评论
回答(1 个)
Supreeth Subbaraya
2014-8-11
Once you have the trained model, you can use the function predict to classify your test data into one of the classes. The documentation for predict can be found here.
posterior function gives the posterior probability of the observations in the test data. It gives the probability with which each test points would fall into each of the classes. The documentation for the posterior function can be found here.
If the term "detection score" means the count of the samples in the test data that have been classified properly, you can find an example to obtain the misclassification rate here. In the section "Examples" on the page, go to "Train Naive Bayes Classifiers Using Multinomial Predictors". Here you can see that if you have a trained Naive Bayes Classifier NBModel, you can find out the misclassification rate by the following lines of code:
predSpam = predict(NBModel,X);
misclass = sum(y'~=predSpam)/n
Here X is the predictors and n is the sample size. You can just get the number of samples misclassified by not dividing by n . Once you have the number of samples misclassified, you can find out the numbers of samples classified correctly. You can use this information to evaluate the performance of your trained model.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Naive Bayes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!