[R] Question in using e1071 svm routine

Steve Lianoglou mailinglist.honeypot at gmail.com
Wed Jul 8 03:32:40 CEST 2009


Hi,

On Jul 7, 2009, at 8:37 PM, Stavros Macrakis wrote:

> Isn't the initial value of the variable T equal to the constant TRUE?
>
> So unless he's modified the value of T, shouldn't it work?

Yes, it should.

Perhaps we should be looking at your data:

> model <- svm(y=factor(mytraindata[, 1]), x=mytraindata[, -1],  
> probability=T)
> Error in if (any(co)) { : missing value where TRUE/FALSE needed
> In addition: Warning message:
> In FUN(newX[, i], ...) : NAs introduced by coercion

1) Where is the "NAs introduced by coercion" warning coming from? When  
you're trying to convert your y into a factor? Are there NA's in your  
predictors or labels?

2) It looks like the codepath that leads to your error: `if  
any(co)) ...` only is meant to execute when `length(scale)` != 1 ...  
why is it going there? (See the source of svm.default to see what I  
mean)

Otherwise, your code should work just fine, see:

R> library(e1071)
Loading required package: class
R> data(iris)
R> model <- svm(y=iris[,5], x=iris[,-5], probability=T)
R> model

Call:
svm.default(x = iris[, -5], y = iris[, 5], probability = T)


Parameters:
    SVM-Type:  C-classification
  SVM-Kernel:  radial
        cost:  1
       gamma:  0.25

Number of Support Vectors:  51

-steve

--
Steve Lianoglou
Graduate Student: Physiology, Biophysics and Systems Biology
Weill Medical College of Cornell University

Contact Info: http://cbio.mskcc.org/~lianos




More information about the R-help mailing list