- “Mdl”: Naïve Bayes classifier model.
- “xdata”: Input data for which you want to calculate the posterior probabilities.
- “PostProbs”: Posterior probabilities of all the classes in your case.
- “labels”: The predicted labels for your input data.
- “MisClassCost”:Misclassification costs for all the classes in each data point.
need to calculates the Posterior probability using fitcnb function classification
3 次查看(过去 30 天)
显示 更早的评论
I need quick help with modifications of the attached code which calculates the prior probability and I need to add a function that calculates the Posterior probability of the data using fitcnb classification function
I tried with to apply similar code of this example but I couldn't fit it into my code
these are the classes inside my dataset
'BENIGN','DrDoS_DNS','DrDoS_LDAP','DrDoS_MSSQL','DrDoS_NetBIOS','DrDoS_NTP','DrDoS_SNMP','DrDoS_SSDP','DrDoS_UDP','Syn','UDP-lag'
where the distribution of BENIGN label should be 50% and the other 50% should be all other labels
Thanks in advance realy appreciate your help
0 个评论
回答(1 个)
Avadhoot
2023-9-26
Hi Ibtihal,
I understand that you have already created a Naïve Bayes Classifier using the “fitcnb” function. To calculate the posterior probabilities, you need to add the following line to your code after the creation of the model.
[labels,PostProbs,MisClassCost] = predict(Mdl,xdata);
The variables in the above line of code contain the following information:
For more information on how the posterior probabilities and misclassification costs are estimated, refer to the following link:
Regards,
Avadhoot.
0 个评论
另请参阅
类别
在 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!