I am making some stochastic training ensemble classes in Python, and I want to get hyperparameters values. Grid search will take too long for moderate data sets, because in my stochastic training I train different learners on different dropouts, as in cross-validation, then I average or weight-average on best error for dropout. Having this set, I want to get best parameter values at every iteration, so I thought to use a genetic algorithm approach.

I found one example on Github, but failed to install, and I am looking for more references of genetic algorithms for doing this. Can anyone help me?

  • $\begingroup$ Try using R? Here is an example: r-bloggers.com/genetic-algorithms-a-simple-r-example I also agree with the answer below. Writing your own code to do a simple GA wouldn't be too difficult. $\endgroup$ – Stu Dec 1 '15 at 22:23
  • $\begingroup$ There is another R package called "GA" which I use from time to time, despite my answer below :) It has the advantage of excellent documentation with many examples. $\endgroup$ – Pete Dec 4 '15 at 19:04

Having used genetic algorithms extensively in both professional projects and for my own entertainment, I think it is best to just code your own set of functions/classes for the specific project. As you have seen, there are quite a few well-intended open-source GA packages out there. However, many of the fine details and tweaks necessary for a good GA are problem-specific. It is also more convenient to work directly with your existing data structures, rather than adapt to someone else's worldview. In other words, cost-benefit does not seem to work out when applying someone else's GA package. You need a function for creating a random instance, a function for checking it is valid, a function for scoring it, and a mating function. That's pretty much it!


I don't know details of algorithm itself, but if you are using Python this module could help you:


I'm using it, and it seems to work nicely.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.