1
votes

I'm trying to get probability output in libSVM (packeage e1071 in R) but the output is only TRUE or FALSE with my dataset.

Follow the code:

dadosBrutos<-read.csv("Dataset/circle.data",header = FALSE)


svm.modelo <- svm(V3 ~ ., 
              data=conjuntoTreinamento,
              type='C-classification',
              probability=TRUE)
              #cost=c, 
              #type='C-classification', 
              #kernel='linear',
              #scale=FALSE, 
              #verbose=FALSE 
svm.predict <- predict(svm.modelo,
                       subset(conjuntoTreinamento, 
                       select = -V3),
                       probability=TRUE)

posterior <- as.matrix(svm.predict)

But, when I use dataset Iris for example, the probability output is % and not the name of class.

library(e1071)

model <- svm(Species ~ ., data = iris, probability=TRUE)
pred <- predict(model, iris, probability=TRUE)
head(attr(pred, "probabilities"))

#      setosa versicolor   virginica
# 1 0.9803339 0.01129740 0.008368729
# 2 0.9729193 0.01807053 0.009010195
# 3 0.9790435 0.01192820 0.009028276
# 4 0.9750030 0.01531171 0.009685342
# 5 0.9795183 0.01164689 0.008834838
# 6 0.9740730 0.01679643 0.009130620

Can someone help me to understand this?

1

1 Answers

1
votes

You have to extract it from the attributes:

attr(svm.predict, "probabilities")

SEE: https://stat.ethz.ch/pipermail/r-help/2006-February/088476.html