Search code examples
matlabclassificationmatlab-figureroc

plot ROC curve for classifier


i'm trying to plot a ROC curve for my classifier in matlab. i have a predicted matrix of 8,000 X 50 binary values (0,1) and test matrix of 8,000 X 50 binary values. (8000 incidents for 50 targets or classes, for each a class there are 8000 different cases.) im using the commands:

[tpr,fpr,thresholds] = roc(testy,predy);
plotroc(testy,predy)

i expect to get 50 curves with 8,000 points from 0 to 1 of course, but what i get is 50 curves with only 3 points.

here is an example of 10 cases: enter image description here

i dont know if use use to commands in the wrong way, or if there is another way to get the ROC curve? thanks for the help!!!


Solution

  • 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.

    X is false positive rate, Y is true positive rate by default. You can change them as well.