The genetic algorithm-based search for the best hyperparameter values is implemented by the Python program, 02-hyperparameter-tuning-genetic.py, which is located at https://github.com/PacktPublishing/Hands-On-Genetic-Algorithms-with-Python/blob/master/Chapter08/02-hyperparameter-tuning-genetic.py.
The following steps describe the main parts of this program:
- We start by setting the lower and upper boundary for each of the float values representing a hyperparameter, as described in the previous subsection – [1, 100] for n_estimators, [0.01, 1] for learning_rate, and [0, 1] for algorithm:
# [n_estimators, learning_rate, algorithm]:BOUNDS_LOW = [ 1, 0.01, 0]BOUNDS_HIGH = [100, 1.00, 1]