How to compute confusion matrix for cross-validated Naive-Bayes model?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Mihaela Jarema
2020-8-10
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?
回答(1 个)
Zuber Khan
2024-9-25
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 个评论
另请参阅
类别
在 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!