Skip to content

help with tune.svm() e1071

2 messages · Salih Tuna, Steve Lianoglou

#
Hi,
On Wed, May 25, 2011 at 4:54 AM, Salih Tuna <salihtuna at gmail.com> wrote:
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.
This depends if you are using a "formula" for x.
What type of object is `data`? What is the result of:

R> is(data)
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