Tune SVM in R - Dependent variable has wrong type
<p>I'm using <code>svm</code> from <code>e1071</code> for a dataset like this:</p>

<pre><code>sdewey &lt;- svm(x = as.matrix(trainS), 
              y = trainingSmall$DEWEY,
              type="C-classification")
</code></pre>

<p>That works just fine, but when I try to tune the cost and gamma like this:</p>

<pre><code>svm_tune &lt;- tune(svm, train.x=as.matrix(trainS), train.y=trainingSmall$DEWEY, type="C-classification",    ranges=list(cost=10^(-1:6), gamma=1^(-1:1)))
</code></pre>

<p>I get this error:</p>

<blockquote>
  <p>Error in tune(svm, train.x = as.matrix(trainS), train.y =
  trainingSmall$DEWEY,  : Dependent variable has wrong type!</p>
</blockquote>

<p>The structure of my training data is this, but with many more lines:</p>

<pre><code>'data.frame':   1000 obs. of  1542 variables:
 $ women.prisoners                                  : int  1 0 0 0 0 0 0 0 0 0 ...
 $ reformatories.for.women                          : int  1 0 0 0 0 0 0 0 0 0 ...
 $ women                                            : int  1 0 0 0 0 0 0 0 0 0 ...
 $ criminal.justice                                 : int  1 0 0 0 0 0 0 0 0 0 ...
 $ soccer                                           : int  0 1 0 0 0 0 0 0 0 0 ...
 $ coal.mines.and.mining                            : int  0 0 1 0 0 0 0 0 0 0 ...
 $ coal                                             : int  0 0 1 0 0 0 0 0 0 0 ...
 $ engineering.geology                              : int  0 0 1 0 0 0 0 0 0 0 ...
 $ family.violence                                  : int  0 0 0 1 0 0 0 0 0 0 ...
</code></pre>

<p>It is a multi-class problem.
I'm not sure of how I could solve this or if there are other ways of finding out the optimal value for the cost and gamma parameters.</p>

<p><a href="https://drive.google.com/open?id=0B7JXHHQ_-5IVZWdPS3ZCcGZ4Y0k" rel="nofollow">Here is an example of my data</a>, and <code>trainS</code> is that data without the first 4 columns (DEWEY, D1, D2 and D3)</p>

<p>Thanks</p>