Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hyperparameter Tuning with Python

You're reading from  Hyperparameter Tuning with Python

Product type Book
Published in Jul 2022
Publisher Packt
ISBN-13 9781803235875
Pages 306 pages
Edition 1st Edition
Languages
Author (1):
Louis Owen Louis Owen
Profile icon Louis Owen
Toc

Table of Contents (19) Chapters close

Preface 1. Section 1:The Methods
2. Chapter 1: Evaluating Machine Learning Models 3. Chapter 2: Introducing Hyperparameter Tuning 4. Chapter 3: Exploring Exhaustive Search 5. Chapter 4: Exploring Bayesian Optimization 6. Chapter 5: Exploring Heuristic Search 7. Chapter 6: Exploring Multi-Fidelity Optimization 8. Section 2:The Implementation
9. Chapter 7: Hyperparameter Tuning via Scikit 10. Chapter 8: Hyperparameter Tuning via Hyperopt 11. Chapter 9: Hyperparameter Tuning via Optuna 12. Chapter 10: Advanced Hyperparameter Tuning with DEAP and Microsoft NNI 13. Section 3:Putting Things into Practice
14. Chapter 11: Understanding the Hyperparameters of Popular Algorithms 15. Chapter 12: Introducing Hyperparameter Tuning Decision Map 16. Chapter 13: Tracking Hyperparameter Tuning Experiments 17. Chapter 14: Conclusions and Next Steps 18. Other Books You May Enjoy

Implementing Random Search

Random Search is one of the variants of the Exhaustive Search hyperparameter tuning group (see Chapter 3) 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 show you how to implement Random Search with NNI using pure Python code.

The following code shows how to implement Random Search with the NNI package. Here, we’ll use pure Python code instead of using nnictl as in the previous section. You can find the more detailed code in the GitHub repository mentioned in the Technical requirements section:

  1. Prepare the model to be tuned in a script. We’ll use the same model.py script as in the previous section.
  2. Define the hyperparameter space in the form of a Python dictionary:
    hyperparameter_space = { 
        'model__n_estimators': {'_type': 'randint', '_value': [5, 200]}, 
      ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime