How to compute confusion matrix for cross-validated Naive-Bayes model?

2 visualizzazioni (ultimi 30 giorni)
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 Commento
Mihaela Jarema
Mihaela Jarema il 10 Ago 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?

Accedi per commentare.

Risposte (1)

Zuber Khan
Zuber Khan il 25 Set 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:
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