[R] How to find AUC in SVM (kernlab package)

Muhammad Subianto msubianto at gmail.com
Fri Nov 24 14:57:55 CET 2006


Dear all,
I was wondering if someone can help me. I am learning SVM for 
classification in my research with kernlab package. I want to know about 
classification performance using Area Under Curve (AUC). I know ROCR 
package can do this job but I found all example in ROCR package have 
include prediction, for example, ROCR.hiv {ROCR}. My problem is how to 
produce prediction in SVM and to find AUC.

Here is a simple example:

library(MASS)
library(kernlab)
library(ROCR)

pimamodel <- ksvm(type ~ .,data=Pima.tr,type="C-svc",C=10,prob.model=TRUE)
pimamodel
fitted(pimamodel)

pima.pred <- predict(pimamodel, Pima.te[,-8], type="probabilities")
pima.pred

# try to find AUC
#predid.no  <- prediction(pima.pred[,1], Pima.te[,8])
#predid.yes <- prediction(pima.pred[,2], Pima.te[,8])
predid <- prediction(pima.pred, Pima.te[,8])
perfid <- performance(predid,"tpr","fpr")
perfid.auc <- performance(predid,"auc")
perfid.auc

Thank you very much for your help.

Best wishes, Muhammad Subianto



More information about the R-help mailing list