How to compute confusion matrix for cross-validated Naive-Bayes model?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Mihaela Jarema
le 10 Août 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?
Réponses (1)
Zuber Khan
le 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 commentaires
Voir également
Catégories
En savoir plus sur Naive Bayes dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!