【发布时间】:2017-05-22 06:46:29
【问题描述】:
我已经拟合了一个 SVM 模型并使用 ROCR 包创建了 ROC 曲线。如何计算曲线下面积 (AUC)?
set.seed(1)
tune.out=tune(svm ,Negative~.-Positive, data=trainSparse, kernel ="radial",ranges=list(cost=c(0.1,1,10,100,1000),gamma=c(0.5,1,2,3,4) ))
summary(tune.out)
best=tune.out$best.model
##prediction on the test set
ypred = predict(best,testSparse, type = "class")
table(testSparse$Negative,ypred)
###Roc curve
yhat.opt = predict(best,testSparse,decision.values = TRUE)
fitted.opt = attributes(yhat.opt)$decision.values
rocplot(fitted.opt,testSparse ["Negative"], main = "Test Data")##
【问题讨论】:
-
嗨,欢迎来到 StackOverflow!您可能想阅读以下内容:stackoverflow.com/questions/5963269/…
标签: r machine-learning roc auc