[R] training svm's with probability flag (re-send in plain text)

From: Jessie Tenenbaum <jessiet_at_stanford.edu>
Date: Sat 05 Aug 2006 - 05:14:17 EST


Hi-

I'm seeing some weirdness with svm and tune.svm that I can't figure out- was wondering if anyone else has seen this? Perhaps I'm failing to make something the expected class?
Below is my repro case, though it *sometimes* doesn't repro. I'm using R2.3.1 on WindowsXP. I was also seeing it happen with R2.1.1 and have seen it on 2 different machines.  

data(iris)
attach(iris)
library(e1071)
train<- iris[c(1:30,50:80,100:130),]
test<- iris[-c(1:30,50:80,100:130),]
y.train<- train$Species
y.test<- test$Species
obj<- tune.svm(train[,-5], y.train, gamma = 2^(-1:1), cost = 2^(2:4), probability=T)
my.svm<- obj$best.model
pred1<- predict(my.svm, test[,-5])
pred2<- predict(my.svm, test[,-5], probability=T) table(pred1, y.test)
table(pred2, y.test)

When I do this, the two different tables often come out different, as below:
> table(pred1, y.test)

            y.test
pred1        setosa versicolor virginica
  setosa         19          0         0
  versicolor      0         18         1
  virginica       0          1        19

> table(pred2, y.test)
y.test pred2 setosa versicolor virginica setosa 18 0 0 versicolor 1 18 1 virginica 0 1 19

>

I'm not sure 1. why the results would differ based on whether I choose to calculate the probabilities, and 2. which one to trust?? Anyone come across this before, or have any ideas?  

thanks,
jessie



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Aug 05 05:18:09 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 05 Aug 2006 - 08:18:11 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.