Question: How do i set different threshold to get multiple values for ROC plot
0
gravatar for Paul
18 months ago by
Paul80
India
Paul80 wrote:

Below is the code I have written to build a SVM model. I am using ROCR package for plotting the ROC plot.

library(e1071)
library(caret)
library(gplots)
library(ROCR)

inTraining <- createDataPartition(data$Class, p = .70, list = FALSE)
training <- data[ inTraining,]
testing  <- data[-inTraining,]

svm.model <- svm(Class ~ ., data = training,cross=10, metric="ROC",type="C-classification",kernel="linear",na.action=na.omit,probability = TRUE)

#prediction and ROC
svm.model$index
svm.pred <- predict(svm.model, testing, probability = TRUE)
c <- as.numeric(svm.pred)
c = c - 1
pred <- prediction(c, testing$Class)
perf <- performance(pred,"tpr","fpr")
plot(perf,fpr.stop=0.1)

I tried following this solution https://stackoverflow.com/questions/16347507/obtaining-threshold-values-from-a-roc-curve But, I get a single threshold cutoff of

 > head(cutoffs)
  cut      fpr      tpr
1 Inf 0.000000 0.000000
2   1 0.173913 0.673913
3   0 1.000000 1.000000

How do I get multiple thresholds to get different Tpr and fpr rates for plotting a ROC curve?

roc threshold svm R e1071 • 703 views
ADD COMMENTlink modified 18 months ago • written 18 months ago by Paul80
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1056 users visited in the last hour