title: how to optimize parameters of of the support vector machine by using the genetic algorithm with R
body: <p>In order to learn the support vector machine, we must determine various parameters. </p>
  
  <p>For example, there are parameters such as cost and gamma. </p>
  
  <p>I am trying to determine sigma and gamma parameters of SVM Using "GA" package and "kernlab" package of R. </p>
  
  <p>I use accuracy as the evaluation function of the genetic algorithm. </p>
  
  <p>I have created the following code, and I ran it. </p>
  
  <pre><code>library(GA) 
  library(kernlab) 
  data(spam) 
  index &lt;- sample(1:dim(spam)[1]) 
  spamtrain &lt;- spam[index[1:floor(dim(spam)[1]/2)], ] 
  spamtest &lt;- spam[index[((ceiling(dim(spam)[1]/2)) + 1):dim(spam)[1]], ] 
  
  f &lt;- function(x) 
  { 
  x1 &lt;- x[1] 
  x2 &lt;- x[2] 
  filter &lt;- ksvm(type~.,data=spamtrain,kernel="rbfdot",kpar=list(sigma=x1),C=x2,cross=3) 
  mailtype &lt;- predict(filter,spamtest[,-58]) 
  t &lt;- table(mailtype,spamtest[,58]) 
  return(t[1,1]+t[2,2])/(t[1,1]+t[1,2]+t[2,1]+t[2,2]) 
  } 
  
  GA &lt;- ga(type = "real-valued", fitness = f, min = c(-5.12, -5.12), max = c(5.12, 5.12), popSize = 50, maxiter = 2) 
  summary(GA) 
  plot(GA) 
  </code></pre>
  
  <p>However, When I call the GA function,the following error is returned. </p>
  
  <p>"No Support Vectors found. You may want to change your parameters" </p>
  
  <p>I can not understand why the code is bad. </p>