Reputation: 11
I am using the roc.curve of the ROCR package which provides a beautiful plot that is colorized according to the used threshold
using this code
library(ROCR)
pred <- prediction(predicted, response)
perf <- performance( pred, "tpr", "fpr" )
plot( perf, colorize = TRUE)
This function plots the ROC curve automatically, and even if it tries to fit in other to find good threshold values, but I have no control over how many thresholds are used or the range of the thresholds picked.
I have found another roc.curve function from another package called ROSE find more here: https://www.rdocumentation.org/packages/ROSE/versions/0.0-4/topics/roc.curve
In this function I have the possibility to set a number of thresholds
library(ROSE)
roc.curve(response, predicted, plotit = TRUE, add.roc = FALSE, n.thresholds=100)
I was wondering if there is a similar option for the function in ROCR package. Thank you PS I was wondering too why my roc curves are not similar, as if the TPR(true positif rate) and FPR(false positif rate) have been inverted
Upvotes: 1
Views: 1142
Reputation: 7959
By definition, a ROC curve goes over all thresholds.
If you limit the number of thresholds you use, like the ROSE package seems to do, this is no longer a ROC curve.
The curve given by ROCR already contains all thresholds between -Inf and +Inf. There is no way you can add more thresholds to it.
Upvotes: 1