Hi,
On Wed, May 25, 2011 at 4:54 AM, Salih Tuna <salihtuna at gmail.com>
wrote:> Hi,
> I am trying to use tune.svm in e1071 package.
> the command i use is
>
> tobj <- tune.svm(labels, data= data, cost = 10^(1:2))
The first few arguments from the method signature for tune.svm is:
tune.svm(x, y = NULL, data = NULL, ...)
I'm assuming your `labels` variable is a vector of class labels (or
real values if you are doing regression) -- this corresponds to the
`y` in the method signature.
Also note in your call to tune.svm, you are missing a correct value
for the `x` parameter.
> Should the last column of the 'data' contain the labels as well?
This depends if you are using a "formula" for x.
>I want to
> use the linear kernel. But it gives me the error
> "Error in model.frame.default(formula, data) : 'data' must be
a data.frame,
> not a matrix or an array"
What type of object is `data`? What is the result of:
R> is(data)
> Do you know why this might happen?
You aren't calling the function correctly.
Either
(1) create a matrix of predictor variables (rows are observations,
columns are features, dimensions, whatever you want to call them) and
a vector of class labels (I guess this is your `labels` variable?).
Do *not* put the class labels as an extra column in your predictor
variable matrix.
Then do:
R> tune.svm(predictors, labels, ...)
or
(2) Use a formula interface and pass in a data.frame as the data argument:
R> tune.svm(y ~ some + thing, data=your.data.frame)
(where 'some' and 'thing' are names of "feature
columns" in
your.data.frame, and "y" is the name of your label column)
Please read through the help pages ?tune and ?tune.svm for more examples.
-steve
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
?| Memorial Sloan-Kettering Cancer Center
?| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact