[R] tune()

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Mon Nov 29 21:34:37 CET 2004


Sending a help request once is enough! Even if you don't have an answer
after 1 hour.

> I am trying to tune an svm by doing the following:
>  
> tune(svm, similarity ~., data = training, degree = 2^(1:2), gamma =
> 2^(-1:1), coef0 = 2^(-1:1), cost = 2^(2:4), type = "polynomial")

I think you want to set `kernel' not `type'...
  
> but I am getting 
>  
> Error in svm.default(x, y, scale = scale, ...) : 
>         wrong type specification!

...checking the argument `type' on ?svm would have told you that.

> I have to admit I am not sure what I am doing wrong.  Could anyone
> tell me why the parameters I am using are wrong? 
>
> Plus could anyone tell me how to go about picking the correct ranges
> for my tuning?

Surprisingly, you have to set `ranges' to specify the ranges of the
parameters, e.g.,

  obj <- tune(svm, Species ~ ., data = iris,
              ranges = list(degree =2^(1:2), gamma = 2^(-1:1),
                            coef0 = 2^(-1:1), cost = 2^(2:4)),
              kernel = "polynomial")

I'm not sure what good ranges are to tune an SVM with a polynomial
kernel...

hth,
Z




More information about the R-help mailing list