Module Expr Str Print NameLoad Import alias identifier ImportFrom alias ImportFrom alias ImportFrom alias identifier ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias Assign NameStore Call NameLoad Assign TupleStore NameStore NameStore TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call NameLoad keyword Num FunctionDef arguments args NameParam NameParam defaults Num body Assign NameStore SubscriptLoad Call NameLoad NameLoad keyword Call NameLoad Num keyword NameLoad Slice NameLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body Print Call AttributeLoad Str attr BinOpAdd NameLoad Num Print Call AttributeLoad Str attr AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Print Call AttributeLoad Str attr AttributeLoad NameLoad attr Print Str decorator_list Assign NameStore Dict Str Str Str Str Str Str ListLoad Num NameLoad Call NameLoad Num Num Call NameLoad Num Num Call NameLoad Num Num ListLoad NameLoad NameLoad ListLoad Str Str Assign NameStore Num Assign NameStore Call NameLoad NameLoad keyword NameLoad keyword NameLoad Assign NameStore Call NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Print BinOpMod Str TupleLoad BinOpSub Call NameLoad NameLoad NameLoad Expr Call NameLoad AttributeLoad NameLoad attr Assign NameStore Dict Str Str Str Str Str Str ListLoad Num NameLoad ListLoad Num Num Num ListLoad Num Num Num ListLoad Num Num Num ListLoad NameLoad NameLoad ListLoad Str Str Assign NameStore Call NameLoad NameLoad keyword NameLoad Assign NameStore Call NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Print BinOpMod Str TupleLoad BinOpSub Call NameLoad NameLoad Call NameLoad AttributeLoad NameLoad attr Expr Call NameLoad AttributeLoad NameLoad attr
N/A N/A 
=========================================================================
Comparing randomized search and grid search for hyperparameter estimation
=========================================================================

Compare randomized search and grid search for optimizing hyperparameters of a
random forest.
All parameters that influence the learning are searched simultaneously
(except for the number of estimators, which poses a time / quality tradeoff).

The randomized search and the grid search explore exactly the same space of
parameters. The result in parameter settings is quite similar, while the run
time for randomized search is drastically lower.

The performance is slightly worse for the randomized search, though this
is most likely a noise effect and would not carry over to a held-out test set.

Note that in practice, one would not search over this many different parameters
simultaneously using grid search, but pick only the ones deemed most important.
 N/A __doc__ N/A numpy np time time operator itemgetter scipy.stats randint sp_randint sklearn.model_selection GridSearchCV sklearn.model_selection RandomizedSearchCV sklearn.datasets load_digits sklearn.ensemble RandomForestClassifier N/A digits N/A load_digits N/A N/A X y N/A N/A digits data N/A digits target N/A clf N/A RandomForestClassifier n_estimators 20 report N/A N/A grid_scores n_top N/A 3 N/A N/A top_scores N/A N/A sorted grid_scores key N/A itemgetter 1 reverse True N/A n_top N/A N/A i score N/A enumerate top_scores N/A N/A N/A N/A Model with rank: {0} format N/A i 1 N/A N/A N/A Mean validation score: {0:.3f} (std: {1:.3f}) format N/A score mean_validation_score N/A N/A np std N/A score cv_validation_scores N/A N/A N/A Parameters: {0} format N/A score parameters N/A N/A N/A param_dist N/A max_depth max_features min_samples_split min_samples_leaf bootstrap criterion N/A 3 None N/A sp_randint 1 11 N/A sp_randint 1 11 N/A sp_randint 1 11 N/A True False N/A gini entropy N/A n_iter_search 20 N/A random_search N/A RandomizedSearchCV clf param_distributions param_dist n_iter n_iter_search N/A start N/A time N/A N/A N/A random_search fit X y N/A N/A RandomizedSearchCV took %.2f seconds for %d candidates parameter settings. N/A N/A N/A time start n_iter_search N/A N/A report N/A random_search grid_scores_ N/A param_grid N/A max_depth max_features min_samples_split min_samples_leaf bootstrap criterion N/A 3 None N/A 1 3 10 N/A 1 3 10 N/A 1 3 10 N/A True False N/A gini entropy N/A grid_search N/A GridSearchCV clf param_grid param_grid N/A start N/A time N/A N/A N/A grid_search fit X y N/A N/A GridSearchCV took %.2f seconds for %d candidate parameter settings. N/A N/A N/A time start N/A len N/A grid_search grid_scores_ N/A N/A report N/A grid_search grid_scores_