【问题标题】:How to correct the error in plotting the ROCR plot?如何纠正绘制 ROCR 图的错误?
【发布时间】:2017-06-02 07:46:20
【问题描述】:

性能错误(pred,“tpr”,“fpr”):错误的参数类型: 第一个参数必须是“预测”类型;第二个和可选的第三个 参数必须是可用的性能度量!

s <- svm(Column20 ~ ., data =train) 
pred <- predict(s, test[,-20]) 
x <-table( pred, test$Column20) 
P <- performance(x, "tpr", "fpr")

如果我将这行代码更改为 x

 Error in prediction(pred, test$Column20) : 
  Format of predictions is invalid.

我没有正确理解错误。你能解释一下我做错了什么吗? 提前致谢

【问题讨论】:

  • 你应该使用x &lt;- prediction( pred, test$Column20)然后P &lt;- performance(x, "tpr", "fpr")
  • s

标签: r


【解决方案1】:

这是一个简单的说明性示例。希望对你有帮助。

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)

【讨论】:

    猜你喜欢
    • 2012-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-25
    • 2010-10-18
    • 1970-01-01
    • 2017-05-15
    相关资源
    最近更新 更多