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
Machine Learning Algorithms

You're reading from  Machine Learning Algorithms

Product type Book
Published in Jul 2017
Publisher Packt
ISBN-13 9781785889622
Pages 360 pages
Edition 1st Edition
Languages
Toc

Table of Contents (22) Chapters close

Title Page
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface
1. A Gentle Introduction to Machine Learning 2. Important Elements in Machine Learning 3. Feature Selection and Feature Engineering 4. Linear Regression 5. Logistic Regression 6. Naive Bayes 7. Support Vector Machines 8. Decision Trees and Ensemble Learning 9. Clustering Fundamentals 10. Hierarchical Clustering 11. Introduction to Recommendation Systems 12. Introduction to Natural Language Processing 13. Topic Modeling and Sentiment Analysis in NLP 14. A Brief Introduction to Deep Learning and TensorFlow 15. Creating a Machine Learning Architecture

Finding the optimal hyperparameters through grid search


Finding the best hyperparameters (called this because they influence the parameters learned during the training phase) is not always easy and there are seldom good methods to start from. The personal experience (a fundamental element) must be aided by an efficient tool such as GridSearchCV, which automates the training process of different models and provides the user with optimal values using cross-validation.

As an example, we show how to use it to find the best penalty and strength factors for a linear regression with the Iris toy dataset:

import multiprocessing

from sklearn.datasets import load_iris
from sklearn.model_selection import GridSearchCV

>>> iris = load_iris()

>>> param_grid = [
   { 
      'penalty': [ 'l1', 'l2' ],
      'C': [ 0.5, 1.0, 1.5, 1.8, 2.0, 2.5]
   }
]

>>> gs = GridSearchCV(estimator=LogisticRegression(), param_grid=param_grid,
   scoring='accuracy', cv=10, n_jobs=multiprocessing...
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 $15.99/month. Cancel anytime