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
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
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:
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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by