Solved – Diagonal in ROC plot

machine learningroc

I've used the R ROCR package to generate an ROC plot. I can see a diagonal in my plot. However, the ROC curve that I see other people generated has only horizontal and vertical lines.

Why would I get a plot like that? Is that possible to have a diagonal line in a legal ROC plot?

ROC curve I see in the literature looks like this:

enter image description here

My generated ROC plot is:

enter image description here

Best Answer

Assume that you have the following result:

score label
1.000 positive
0.900 negative
0.900 positive
0.900 negative
0.500 negative
0.200 positive

Manually plot the ROC curve for the possible thresholds of 1.0, 0.9, 0.5, 0.2 and you do get a sloped part.

The reason are duplicate scores.

Beware, there are some poor implementations of ROC out there. I've seem some that only sample values (usually you can recognize this because they have very evenly spaced steps), and I've seen implementations that simply sort the data and then take the nth object - ignoring duplicate scores. If the input data is presorted by label, this causes results to be much better than expected. This can be detected by using a data set where all scores are 0 - the only correct result then is the diagonal line and a AuC of 0.5

Related Question