SVMモデルを採用し、ROC曲線をROCRパッケージで作成しました。曲線下面積(AUC)をどのように計算できますか?ROCRパッケージでAUCを計算する方法
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),
probability = TRUE)) # train svm with probability option true
summary(tune.out)
best=tune.out$best.model
yhat.opt = predict(best,testSparse,probability = TRUE)
# Roc curve
library(ROCR)
# choose the probability column carefully, it may be
# probabilities[,1] or probabilities[,2], depending on your factor levels
pred <- prediction(attributes(yhat.opt)$probabilities[,2], testSparse$Negative)
perf <- performance(pred,"tpr","fpr")
plot(perf,colorize=TRUE)
が
こんにちは、!これを読んでみてください:http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example –