[R] training svm's with probability flag

2006-08-04 Thread Jessie Tenenbaum
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
pred1setosa versicolor virginica
  setosa 19  0 0
  versicolor  0 18 1
  virginica   0  119
 table(pred2, y.test)
y.test
pred2setosa versicolor virginica
  setosa 18  0 0
  versicolor  1 18 1
  virginica   0  119
 

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

[[alternative HTML version deleted]]

__
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.


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

2006-08-04 Thread Jessie Tenenbaum
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
pred1setosa versicolor virginica
  setosa 19  0 0
  versicolor  0 18 1
  virginica   0  119
 table(pred2, y.test)
y.test
pred2setosa versicolor virginica
  setosa 18  0 0
  versicolor  1 18 1
  virginica   0  119
 

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.