December 2018
Beginner to intermediate
684 pages
21h 9m
English
sklearn provides a method to define ranges of values for multiple hyperparameters. It automates the process of cross-validating the various combinations of these parameter values to identify the optimal configuration. Let's walk through the process of automatically tuning your model.
The first step is to instantiate a model object and define a dictionary where the keywords name the hyperparameters, and the values list the parameter settings to be tested:
clf = DecisionTreeClassifier(random_state=42)param_grid = {'max_depth': range(10, 20), 'min_samples_leaf': [250, 500, 750], 'max_features': ['sqrt', 'auto'] }
Then, instantiate the GridSearchCV object, providing the estimator object and parameter grid, ...