January 2020
Beginner to intermediate
432 pages
11h 24m
English
Execute the following steps to run both grid search and randomized search on the decision tree pipeline we have created in the Implementing scikit-learn's pipelines recipe.
from sklearn.model_selection import (GridSearchCV, cross_val_score, RandomizedSearchCV, cross_validate, StratifiedKFold)
k_fold = StratifiedKFold(5, shuffle=True, random_state=42)
cross_val_score(tree_pipeline, X_train, y_train, cv=k_fold)
This results in an array containing the estimator's default score (accuracy) values:
array([0.73193085, 0.735625, 0.71458333, 0.72395833, 0.72619296])
cross_validate(tree_pipeline, ...
Read now
Unlock full access