ROC curve AlexNet CNN

How to calculate the ROC curve using AlexNet CNN from Matlab? I have two class.

Answers (3)

Gledson Melotti
Gledson Melotti on 4 Oct 2018

1 vote

cgt = double(testeImagesLabels); clabel = double(Test_predict); cscores = double(Probability);
figure(2) [X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(cgt,cscores(:,1),1); plot(X,Y,'k');

8 Comments

May I know what is your testeImagesLabels,Test_predict and Probability?
testeImagesLabels are my labels ground true, that is, true classes. Test_predict is my result after prediction.
How to plot when we have 6 classes?
Hi, You make one against all.
I have 12 classes , how to make it one agaist all 12 ?
Peter
Peter on 21 Feb 2022
Please see the Plot ROC Curve for Classification Tree example in the perfcurve discription for how to do this.
Jhalak Mehta
Jhalak Mehta on 12 Apr 2022
Edited: Jhalak Mehta on 12 Apr 2022
How do I get the probability?
classNames = net.Layers(end).Classes;
rocSmallNet = rocmetrics(imdsTest.Labels,score,classNames);
p = plot(rocSmallNet,ShowModelOperatingPoint=false)

Sign in to comment.

Salma Hassan
Salma Hassan on 20 Feb 2018

0 votes

sir did you find the solution i have the same problem

8 Comments

Not. If you find it, please send it to me.
did u find any solution?
Gledson Melotti
Gledson Melotti on 10 Apr 2018
Edited: Gledson Melotti on 10 Apr 2018
Hello.
[predictedLabels,scores]=classify(myNet,testeImages);
cgt = double(testeImagesLabels);
cscores = scores;
figure(1)
[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(cgt,cscores(:,1),1);
plot(X,Y);
grid
xlabel('False positive rate')
ylabel('True positive rate')
title('ROC for Classification CNN')
sir i change my code to yours and i got this figure
and if i change the line into score(:,2),1 i got this
which one is true
The second figure is True.
Sir, may i have your code plss.
cgt = double(testeImagesLabels); clabel = double(Test_predict); cscores = double(Probability);
figure(2) [X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(cgt,cscores(:,1),1); plot(X,Y,'k');
Please can you help me in the section, becuase I have error thanks

Sign in to comment.

Hiren Mewada
Hiren Mewada on 25 Jan 2024

0 votes

[predictions,score] = classify(net, imdsTest); % To get prediction score from last layer for each class
classNames = net.Layers(end).Classes;
rocSmallNet = rocmetrics(imdsTest.Labels,score,classNames);
p = plot(rocSmallNet,ShowModelOperatingPoint=false)

Asked:

on 20 Dec 2017

Answered:

on 25 Jan 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!