4

I have a binary classifier, which classifies an input X as class zero if its predicted value is below some threshold (say T), and one otherwise.
I have all predicted and actual values for every input. So I can have both predicted class and actual class of an input.

Now I want to have the ROC curve for this classifier with MATLAB. How should I do it?

Matin Kh
  • 5,192
  • 6
  • 53
  • 77

1 Answers1

5

Use perfcurve:

[X,Y] = perfcurve(labels,scores,posclass);
plot(X,Y);

labels are the true labels of the data, scores are the output scores from your classifier (before the threshold) and posclass is the positive class in your labels.

Ran
  • 4,117
  • 4
  • 44
  • 70
  • What do `X` and `Y` represent? – Matin Kh Dec 15 '13 at 22:24
  • 1
    @MatinKh X is false positive rate, Y is true positive rate by default. You can change them as well. Check this page: http://www.mathworks.com/help/stats/perfcurve.html – lennon310 Dec 15 '13 at 23:38
  • @MatinKh `X` and `Y` are the values for the axis of the ROC plot. – Ran Dec 16 '13 at 09:07
  • @Ran You have mentioned that scores are output scores from classifier before applying threshold. Then how do we apply threshold – TariqS May 08 '20 at 10:47