title: How to optimize parameters using genetic algorithms
body: <p>I'd like to optimize three parameters (gamma, cost and epsilon) in eps-regression (SVR) using GA in R. Here's what I've done.</p>
  <pre><code>library(e1071)
  data(Ozone, package=&quot;mlbench&quot;)
  a&lt;-na.omit(Ozone)
  index&lt;-sample(1:nrow(a), trunc(nrow(a)/3))
  trainset&lt;-a[index,]
  testset&lt;-a[-index,]
  model&lt;-svm(V4 ~ .,data=trainset, cost=0.1, gamma=0.1, epsilon=0.1, type=&quot;eps-regression&quot;, kernel=&quot;radial&quot;)
  error&lt;-model$residuals
  rmse &lt;- function(error) #root mean sqaured error
  {
    sqrt(mean(error^2))
  }
  rmse(error)
  </code></pre>
  <p>Here, I set cost, gamma and epsilon to be 0.1 respectively, but I don't think they are the best value. So, I'd like to employ Genetic Algorithm to optimize these parameters.</p>
  <pre><code>GA &lt;- ga(type = &quot;real-valued&quot;, fitness = rmse,
           min = c(0.1,3), max = c(0.1,3),
           popSize = 50, maxiter = 100)
  </code></pre>
  <p>Here, I used RMSE as the fitness function. but I think fitness function has to include the parameters that are to be optimized. But, in SVR, the objective function is too complicated to write out with R code, which I tried to find for a LONG time but to no avail. Someone who knows SVR and GA at the same time, someone who has an experience of optimizing SVR parameters using GA, Please help me. please.</p>