Tuning A CART's Hyperparameters: Elie Kawerk
Tuning A CART's Hyperparameters: Elie Kawerk
hyperparameters
MA CH IN E LEA RN IN G W ITH TREE-BA S ED MODELS IN P YTH ON
Elie Kawerk
Data Scientist
Hyperparameters
Machine learning model:
Random Search
Bayesian Optimization
Genetic Algorithms
....
The optimal hyperparameters are those of the model achieving the best CV score.
Best hyerparameters:
{'max_depth': 3, 'max_features': 0.4, 'min_samples_leaf': 0.06}
Elie Kawerk
Data Scientist
Random Forests Hyperparameters
CART hyperparameters
number of estimators
bootstrap
....
computationally expensive,
# Instantiate 'grid_rf'
grid_rf = GridSearchCV(estimator=rf,
param_grid=params_rf,
cv=3,
scoring='neg_mean_squared_error',
verbose=1,
n_jobs=-1)
Best hyerparameters:
{'max_depth': 4,
'max_features': 'log2',
'min_samples_leaf': 0.1,
'n_estimators': 400}
Elie Kawerk
Data Scientist
How far you have come
Chapter 1: Decision-Tree Learning