Naive Bayes Posterior Probability
1 view (last 30 days)
Show older comments
Hi,
I am using a Naive Bayes Classifier which I train with:
Mdl = fitcnb(data,target,...
'Holdout',0.10,...
'OptimizeHyperparameters','auto',...
'HyperparameterOptimizationOptions',...
struct('AcquisitionFunctionName','expected-improvement-plus'));
So when I predit the class of the data results in values of 0 and 1, because I only have two classes. This is pretty nice, but I need to know the certainty of this estimate. So I want to have something like:
class 1: probability 0.4
class 2: probability 0.6
or something like this.
Is the correct function for this the posterior function? As far as I understood it this function is only available for the deprecated NaiveBayes class.
Does anybody know how I can get the probability of the estimate?
0 Comments
Accepted Answer
Don Mathis
on 29 Aug 2017
You can get the posterior probabilities from the second output of the predict method. See this page: http://www.mathworks.com/help/stats/compactclassificationnaivebayes.predict.html
[label,Posterior] = predict(Mdl,X)
0 Comments
More Answers (0)
See Also
Categories
Find more on Naive Bayes in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!