How can I create an ROC plot from the set of cross-validation models using Statistics Toolbox 7.5 (R2011a)?
10 views (last 30 days)
Show older comments
MathWorks Support Team
on 13 Mar 2012
Edited: MathWorks Support Team
on 13 Dec 2021
I am using the CROSSVAL command to validate the performance of 'NaiveBayes' model for my data. I am computing the metrics, misclassification rate and confusion matrix using stratified 10-fold cross-validation to analyze the performance of the classifier. I intend to create an ROC curve from the validation results. Is there any way to create ROC plot from the cross-validation results of my model using Statistics Toolbox 7.5 (R2011a)?
Accepted Answer
MathWorks Support Team
on 10 Dec 2021
Edited: MathWorks Support Team
on 13 Dec 2021
In order to plot ROC curve, the decision boundary should be a value of the posterior probabilities that you compute using ‘NaiveBayes’. You can plot ROC curves using PERFCURVE, which computes the ROC curve for a vector of classifier predictions, given the true class. More details about PERFCURVE are available via the following link:
Here is a small example of how to plot an ROC curve without cross-validation:
load fisheriris
x = meas(51:end,1:2);
y = species(51:end);
nb = NaiveBayes.fit(x,y);
p = posterior(nb,x);
[X,Y] = perfcurve(y,p(:,1),'versicolor');
plot(X,Y)
xlabel('False positive rate'); ylabel('True positive rate')
title('ROC for classification by naïve Bayes')
To use 10-fold cross-validation, you can fit the model on 90% of the data, and compute predicted posteriors for the remaining 10% of data which was not used for fitting. You can then loop over each of the 10 subsets to plot the ROC curves for individual runs.
0 Comments
More Answers (0)
See Also
Categories
Find more on Classification Trees 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!