Tuning models with grid search

Recall from Chapter 3, Classification and Regression with K-Nearest Neighbors that hyperparameters are parameters of the model that the learning algorithm does not estimate. For example, hyperparameters of our logistic regression SMS classifier include the value of the regularization term and thresholds used to remove words that appear too frequently or infrequently. In scikit-learn, hyperparameters are set through the constructors of estimators and transformers. In the previous examples, we did not set any arguments for LogisticRegression; we used the default values for all of the hyperparameters. These default values are often a good start, but they may not produce the optimal model. Grid search is a common ...

Get Mastering Machine Learning with scikit-learn - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.