Implementing Tree-structured Parzen Estimators
Tree-structured Parzen Estimators (TPEs) are one of the variants of the Bayesian Optimization hyperparameter tuning group (see Chapter 4) that the NNI package can implement. Let’s use the same data, pipeline, and hyperparameter space as in the example in the previous section to implement TPE with NNI using pure Python code.
The following code shows how to implement TPE with the NNI package using pure Python code. You can find the more detailed code in the GitHub repository mentioned in the Technical requirements section:
- Prepare the model to be tuned in a script. We’ll use the same
model.py
script as in the previous section. - Define the hyperparameter space in the form of a Python dictionary. We’ll use the same hyperparameter space as in the previous section.
- Set up the experiment configurations via the
Experiment
class. Note that there are three parameters for the TPE tuner:optimize_mode
,seed
,...