Ensembles and hyperparameter tuning

Predicting CTR with Machine Learning in Python

Kevin Huo

Instructor

Ensemble methods

Example of bootstrap aggregation

  • Bagging: random samples selected for different models, then models are individually trained and combined.
Predicting CTR with Machine Learning in Python

Random forests

clf = RandomForestClassifier()
print(clf)
RandomForestClassifier(
  bootstrap=True,
  ...
  max_depth = 10,
  ...
  n_estimators = 100,
  ...)
Predicting CTR with Machine Learning in Python

Hyperparameter tuning

  • Hyperparameter: parameters configured before training, and external to a model
  • Examples of parameters but NOT hyperparameters: slope coefficient in linear regression, weights in logistic regression, etc.
  • Examples of hyperparameters: max_depth, n_estimators, etc.
Predicting CTR with Machine Learning in Python

Grid search

param_grid = {'n_estimators': n_estimators, 
              'max_depth': max_depth}
clf = GridSearchCV(estimator = model, 
                   param_grid = param_grid, 
                   scoring = 'roc_auc')
print(clf.best_score_)
print(clf.best_estimator_)
0.6777
RandomForestClassifier(max_depth = 100, ...)
Predicting CTR with Machine Learning in Python

Let's practice!

Predicting CTR with Machine Learning in Python

Preparing Video For Download...