How do i set different threshold to get multiple values for ROC plot
0
0
Entering edit mode
5.5 years ago
Paul ▴ 80

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 R SVM e1071 threshold • 2.0k views
ADD COMMENT

Login before adding your answer.

Traffic: 2749 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6