ROC curve for a binary classifier in MATLAB

11,601

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.

Share:
11,601

Related videos on Youtube

Matin Kh
Author by

Matin Kh

I have a PhD in Computer Science and am a software engineer at Google. Previously, I was a research assistant at the University of Florida and a research scientist intern at Philips Research North America. I was also a teaching assistant for Analysis of Algorithms Data Mining Database Management Systems I am interested in algorithms, programming, machine learning, and statistics.

Updated on June 04, 2022

Comments

  • Matin Kh
    Matin Kh almost 2 years

    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
    Matin Kh over 10 years
    What do X and Y represent?
  • lennon310
    lennon310 over 10 years
    @MatinKh X is false positive rate, Y is true positive rate by default. You can change them as well. Check this page: mathworks.com/help/stats/perfcurve.html
  • Ran
    Ran over 10 years
    @MatinKh X and Y are the values for the axis of the ROC plot.
  • TariqS
    TariqS almost 4 years
    @Ran You have mentioned that scores are output scores from classifier before applying threshold. Then how do we apply threshold