Get startedGet started for free

Visualizing a Random Search

Visualizing the search space of random search allows you to easily see the coverage of this technique and therefore allows you to see the effect of your sampling on the search space.

In this exercise you will use several different samples of hyperparameter combinations and produce visualizations of the search space.

The function sample_and_visualize_hyperparameters() takes a single argument (number of combinations to sample) and then randomly samples hyperparameter combinations, just like you did in the last exercise! The function will then visualize the combinations.

If you want to see the function definition, you can use Python's handy inspect library, like so:

print(inspect.getsource(sample_and_visualize_hyperparameters))

This exercise is part of the course

Hyperparameter Tuning in Python

View Course

Exercise instructions

  • Confirm how many possible hyperparameter combinations there are in combinations_list by assigning to the variable number_combs and print this out.
  • Sample and visualize 50, 500 and 1500 combinations. You will use a loop for succinctness. What do you notice about the visualization?
  • Now sample and visualize the entire set of combinations. You have already made a variable to assist with this. What does this look like?

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Confirm how many hyperparameter combinations & print
number_combs = ____(____)
print(____)

# Sample and visualise specified combinations
for x in [____, ____, ____]:
    sample_and_visualize_hyperparameters(x)
    
# Sample all the hyperparameter combinations & visualise
____(____)
Edit and Run Code