Grid and Random Search Side by Side
Visualizing the search space of random and grid search together allows you to easily see the coverage that each technique has and therefore brings to life their specific advantages and disadvantages.
In this exercise, you will sample hyperparameter combinations in a grid search way as well as a random search way, then plot these to see the difference.
You will have available:
combinations_list
which is a list of combinations oflearn_rate
andmin_samples_leaf
for this algorithm- The function
visualize_search()
which will make your hyperparameter combinations into X and Y coordinates and plot both grid and random search combinations on the same graph. It takes as input two lists of hyperparameter combinations.
If you wish to view the visualize_search()
function definition, you can run this code:
import inspect
print(inspect.getsource(visualize_search))
This exercise is part of the course
Hyperparameter Tuning in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Sample grid coordinates
grid_combinations_chosen = ____[0:____]
# Print result
print(____)