Experimental genetic algorithm for parameter optimization.
Performs global optimization of hyperparameters based on the log marginal likelihood as a measure of fitness. Currently works with a private code. This should become open source soon.
The easiest way to install the code is with:
pip install git+https://github.com/pcjennings/GeneticAlgorithm.git
This will automatically install the code as well as the dependencies. Alternatively, you can clone the repository to a local directory with:
git clone https://github.com/pcjennings/GeneticAlgorithm.git
And then put the <install_dir>/
into your $PYTHONPATH
environment variable.
Be sure to install dependencies in with:
pip install -r requirements.txt
numpy
In the most basic form, it is possible to set up a search using the following lines of code:
# Setup the GA search.
ga = GeneticAlgorithm(
pop_size=50,
fit_func=fitness_func,
d_param=[5, 3],
pop=None
)
# Run GA search.
ga.search(500)
In this case, the fitness_func
can be any user defined fitness function. The
d_param
variable gives the dimensionality of the model parameters to be
optimized.