Plotting ROC Curve for Multiclass
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I'm trying to make a multiclass ROC Curve and i think i'm close to it but it doesn't work. I've spent quite a while to figure out where the problem is, yet it came to nothing. I'm curious could someone who had done it before can help me ?
Firstly I have the classes below.
template=templateSVM('Standardize',true,'KernelFunction','gaussian')
MultiClassSVM=fitcecoc(winedataset,'quality','Learners',template,'FitPosterior',true)
yPredicted=predict(MultiClassSVM,winedataset)
fprintf(sprintf('Training accuracy: %0.2f%%', 100*mean(yPredicted==winedataset.quality)));
confusionchart(winedataset.quality,yPredicted,'RowSummary','row-normalized')
MultiClassSVM.ClassNames
ans =
3
4
5
6
7
8
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/617613/image.jpeg)
This is my confusion matrix. Furthermore, I'm using the code below to create a ROC curve.
[~,score_svm] = resubPredict(MultiClassSVM);
diffscore=zeros;
for i=1:size(score_svm,1)
temp=score_svm(i,:);
diffscore(i,:)=temp(2)-max([temp(1),temp(3),temp(4),temp(5),temp(6)]);
end
[X,Y,T,~,OPTROCPT,suby,subnames] = perfcurve(winedataset.quality,diffscore,4)
plot(X,Y)
hold on
plot(OPTROCPT(1),OPTROCPT(2),'ro')
xlabel('False positive rate')
ylabel('True positive rate')
title('ROC for Classification by SVM')
fprintf("Area Under the Curve (AUC) = %f",AUCsvm)
hold off
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/617618/image.jpeg)
Well the curve is supposed to have a value like 0.94 yet it shows 1. I probably made a mistake while calculating diffscore but i'm not quite sure of it. I would appreciate if anyone who has done it before could help.
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Statistics and Machine Learning Toolbox 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!