January 2020
Beginner to intermediate
372 pages
10h
English
We can perform decision tree discretization with scikit-learn within a grid search to find the optimal parameters to determine the most predictive decision tree. To do so, we first do the imports, as in step 1 of the main recipe, and we add one additional import:
from sklearn.model_selection import GridSearchCV
Next, let's load the dataset and divide it into train and test sets, as in step 2 and step 3 of the main recipe, and now let's set up a parameter search grid.
param_grid = {'max_depth': [1,2,3,4]}
Read now
Unlock full access