Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I want to plot a ROC for my detection algorithm which is used to detect features in image. I had obtained true positive, false positive and false negative from the algorithm. There is no true negative in my case.

   I had run the algorithm for 6 images so i got 6 number of TP,FP and FN. With

this how can i plot the ROC curve.

Threshold 1

TP    FP    FN
1066  70    116
1176  67    201
890   42    129
1040  69    74
677   88    94
1284  73    123

Threshold 2

TP  FP  FN
446 41  55
180 15  42
221 16  62
304 23  56
170 39  23
310 31  74

I am new to ‘R’, so I also need to know how to plot it in R?

share|improve this question
2  
(-1) This question makes no sense. Please reread the definition of the ROC-curve and edit / delete your question appropriately. The important point is in the first sentence, i.e. as its discrimination threshold is varied. By reporting the (although not complete) confusion matrix for all your images, you already have chosen a threshold. – steffen Aug 11 '12 at 9:52
1  
thank you for the edit, but the format is broken now. Can you please please fix it ? I suggest to use the code formatting ("{}" in the options above the textfield) to format the table. Another question: It is absolute mandatory that the answer uses SPSS, Sigmaplot or origin ? What about R ? – steffen Aug 12 '12 at 18:24
Sorry for bothering you, but I am afraid there is still something wrong. How is the data for the two thresholds related ? First I have assumed that the first row of Threshold1 corresponds to the first row of Threshold2, both representing the first image. But then I wonder why TP+FN=All Positives are not the same for both classes ? Can you please clarify ? Maybe helpful: confusion matrix (scroll down) – steffen Aug 13 '12 at 11:51
from the comment to sebp's answer I have recognized you just need the codez ... this is not what the site has been created for. Our main goal is education and building knowledge, not doing the work for you. I want you to know that the question still might be answered, but probability might not be high. – steffen Aug 13 '12 at 12:01

1 Answer

There are R packages that already implemented what you are trying to achieve, e.g. ROCR. If you want to implement it yourself I'd suggest that you familiarize yourself with ROC curves first, for instance by reading the following paper:

Fawcett, T. (2006). An introduction to ROC analysis. Pattern Recognition Letters, 27(8), 861–874.

share|improve this answer
Thank you for your quick response and for the paper. But right now i need a direct code to run and get the ROC curve for the given data. How it can be done? I know i am skipping a lot but now i need it quickly that is the reason i need direct code to put in R and view the results. – vijay Aug 13 '12 at 11:37
The paper I mentioned contains pseudo code for that as well. If you don't have much time, why not just use one of the already existing packages? – sebp Aug 13 '12 at 14:02
Thanks for encouragement still some confusion. By varying the threshold in algorithm, I had run it for six images with threshold 1 then same six images underwent with threshold, thus got two different set of tp,fp and fn. They will differ in my case and they depict the features detected. First row represents first image, then correspondingly in both cases. So now my question is how to plot ROC in this case. Can it is possible to plot detection of threshold 1 of all six images against thehreshold2. I am bit confused. Is it I am in correct path? Suggest me in this regard. – vijay Aug 14 '12 at 5:17
"ROCR currently supports only evaluation of binary classification tasks" is the output when i tried to input tpr and fpr in the rocr. Now any one suggest me how to plot roc curve. So, i tried with the r question number 9308227 and used that code to plot roc. I got two curve is it correct? – vijay Aug 16 '12 at 7:32
The input is not TPR and FPR, it is the prediction score and actual class. The reference manual is pretty clear about that. You can also have a look at bioinformatics.oxfordjournals.org/content/21/20/3940.abstract – sebp Aug 16 '12 at 7:36
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.