How to compute confusion matrix for cross-validated Naive-Bayes model?
2 views (last 30 days)
Show older comments
1) Let mdlNB be a Naive-Bayes-classification-model. Then you can compute the confusion matrix as follows:
N=resubPredict(mdlNB)
[ldaResubCM,grpOrder]=confusionmat(resp,N)
2) Let mdlNBCV be a cross-validated-Naive-Bayes-Model (e.g.
mdlNBCV=crossval(mdlNB, 'CVPartition', cp)
)
Then the code above doesn't work:
NCV=resubPredict(mdlNBCV)
"Undefined function 'resubPredict' for input arguments of type 'classreg.learning.partition.classification.PartitionedModel'
How can I resolve this problem?
1 Comment
Mihaela Jarema
on 10 Aug 2020
I think the code does not work, because mdlNB is a ClassificationNaiveBayes classifier, while mldNBCV is not a ClassificationNaiveBayes model, but a ClassificationPartitionedModel cross-validated, naive Bayes model, with a different set of methods. How about using another method instead, maybe kfoldPredict?
Answers (1)
Zuber Khan
on 25 Sep 2024
Hi,
You are facing this error because "mdlNBCV" is cross-validated classification model which means that it belongs to a set of classification models trained on cross-validated folds. For more information, you can refer to the following documentation:
https://www.mathworks.com/help/stats/classreg.learning.partition.classificationpartitionedmodel.html
As stated in the above documentation, in order to estimate the quality of classification by cross-validation, you should use KFOLD methods such as kfoldPredict, kfoldLoss, kfoldMargin, kfoldEdge, and kfoldfun.
On the other hand, resubPredict function classify data using a classification machine learning model, specified as a full classification model object. A list of supported models can be found here:
I hope this answers your query.
Regards,
Zuber
0 Comments
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!