Reputation: 53
Error in performance(pred, "tpr", "fpr") : Wrong argument types: First argument must be of type 'prediction'; second and optional third argument must be available performance measures!
s <- svm(Column20 ~ ., data =train)
pred <- predict(s, test[,-20])
x <-table( pred, test$Column20)
P <- performance(x, "tpr", "fpr")
if I change this line of code as x <-prediction( pred, test$Column20), im getting this error
Error in prediction(pred, test$Column20) :
Format of predictions is invalid.
I do not understand the error properly.could you please explain what I have done wrong? Thanks in advance
Upvotes: 1
Views: 3189
Reputation: 24272
Here is a simple illustrative example. I hope it can help you.
library(e1071)
library(ROCR)
df <- iris[,1:4]
df$virgi <- as.numeric(iris$Species=="virginica")
svmMod <- svm(virgi ~ ., data = df)
svmPred <- predict(svmMod, df[,-5])
svmPredictiction <- prediction(svmPred, df$virgi)
svmPerf <- performance(svmPredictiction, "tpr", "fpr")
plot(svmPerf)
Upvotes: 1