I have difficulties to understand predict.svm
.
Please find an illustration of my confusion below.
As we can see, results are different depending on the probability
argument of predict()
.
So my question is: what is the difference between probability=TRUE
and probability=FALSE
?
library(e1071)
# some illustrative data
data(iris)
attach(iris)
x <- subset(iris, select=-Species)
y <- factor(Species == "setosa")
# SVM
SVM <- svm(y ~ x[, 1], probability=TRUE)
# predictions with 'probability=FALSE'
pred <- predict(SVM, x[, 1], probability=FALSE)
table(true=iris$Species == "setosa", pred=pred)
# pred
# true FALSE TRUE
# FALSE 93 7
# TRUE 5 45
# predictions with 'probability=TRUE'
pred <- predict(SVM, x[, 1], probability=TRUE)
table(true=iris$Species == "setosa", pred=pred)
# pred
# true FALSE TRUE
# FALSE 94 6
# TRUE 10 40
Best Answer
From the documentation you can read that see
?svm
(or here):Some more information can be found in libsvm documentation that
svm
function uses, and in JSS article Support Vector Machines in R.