CommencerCommencer gratuitement

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))

Cet exercice fait partie du cours

Hyperparameter Tuning in Python

Afficher le cours

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?

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de 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
____(____)
Modifier et exécuter le code