title: Tuning SVM parameters using svm.tune e1071 package
body: <p>I am trying to perform classification using Support Vector Machines in R using e1071 package. Using the following code, and specifying the cost and gamma parameters, I could train the models successfully.</p>
  <pre><code>svm_models &lt;- lapply(training_data,
                  function(data)
                  {
                    svm(label~., data=data,
                        method=&quot;C-classification&quot;, kernel=&quot;radial&quot;,
                        cost=10, gamma=0.1)
                  })
  </code></pre>
  <p>But If I perform paramter tuning within the above function as the following code,</p>
  <pre><code>svmmodels &lt;- lapply(trainingdata,
                  function(data)
                  {
                    params &lt;- tune.svm(label~., data=data,
                                      gamma=10^(-6:-2), cost=10^(1:2))
                    svm(label~., data=data,
                        method=&quot;C-classification&quot;, kernel=&quot;radial&quot;,
                        cost=params$best.parameter[[2]], gamma=params$best.parameter[[1]])
                  })
  </code></pre>
  <p>then I get the following error:</p>
  <blockquote>
  <p>Error in predict.svm(ret, xhold, decision.values = TRUE) (from #4) :
  Model is empty!</p>
  </blockquote>
  <p>What could be the possible cause of this issue?</p>
  <p>Thanks.</p>