Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- svm.fit <- svm(label ~ NDAI + SD + CORR, data = trainSet, scale = FALSE, kernel = "radial", cost = 2, probability=TRUE)
- svm.pred <- predict(svm.fit, testSet, probability=TRUE)
- mean(svm.pred== testSet$label)*100
- prediction.svm <- prediction(attr(svm.pred, "probabilities")[,2], testSet$label)
- eval.svm <- performance(prediction.svm, "acc")
- roc.svm <- performance(prediction.svm, "tpr", "fpr")
- #identify best values and cutoff
- max_index.svm <- which.max(slot(eval.svm, "y.values")[[1]])
- max.acc_svm <- (slot(eval.svm, "y.values")[[1]])[max_index.svm]
- opt.cutoff_svm <- (slot(eval.svm, "x.values")[[1]])[max_index.svm][[1]]
- #AUC
- auc.svm <- performance(prediction.svm, "auc")
- auc.svm <- unlist(slot(auc.svm, "y.values"))
- auc.svm <- round(auc.svm, 4)
- plot(roc.svm,colorize=TRUE)
- points(0.072, 0.93, pch= 20)
- legend(.6,.2, auc.svm, title = "AUC", cex = 0.8)
- legend(.8,.2, round(opt.cutoff_svm,4), title = "cutoff", cex = 0.8)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement