
How to plot ROC for multi class?
1 view (last 30 days)
Show older comments
I have 5 class and want to plot ROC for it and i am able to plot for binary class but not for 5 class.Please guide me to plot ROC for 5 classes.Many places i have read that ROC is not for multi class if yes then what is for multi class.
0 Comments
Answers (1)
Abhipsa
on 20 Feb 2025
You are correct that ROC curves are commonly used for evaluating the performance of binary classification models. For multi-class classification, ROC analysis can be extended using methods like One-vs-Rest (OvR) or One-vs-One (OvO).
You can refer to the attached “roc.m” file for a complete working example.
The below figure is the output of “roc.m”:

The zest of this example lies in using a loop which iterates over each class in a multi-class classification problem to compute and plot ROC curves using the “One-vs-Rest” approach. For each class, it creates a binary label vector where the current class is treated as the "positive" class. It then uses the “perfcurve” function to calculate the False Positive Rate and True Positive Rate for the class, based on the predicted scores.
You can read more about “perfcurve” by using the MATLAB command
>> doc perfcurve
Moreover, if you are using MATLAB R2022a or any later release, then you can use “rocmetrices” to plot ROC curve for multi-class classification.
You can refer to the following documentation for more details about “rocmetrices”:
For an example, you can use the MATLAB command :
openExample('stats/PlotROCCurveForMulticlassClassificationExample')
I hope this helps!
0 Comments
See Also
Categories
Find more on ROC - AUC 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!