Ensemble e tuning degli iperparametri

Prevedere il CTR con il Machine Learning in Python

Kevin Huo

Instructor

Metodi ensemble

Esempio di bootstrap aggregation

  • Bagging: campioni casuali per modelli diversi; ogni modello è addestrato separatamente e poi combinato.
Prevedere il CTR con il Machine Learning in Python

Random forest

clf = RandomForestClassifier()
print(clf)
RandomForestClassifier(
  bootstrap=True,
  ...
  max_depth = 10,
  ...
  n_estimators = 100,
  ...)
Prevedere il CTR con il Machine Learning in Python

Tuning degli iperparametri

  • Iperparametro: impostato prima dell’addestramento, esterno al modello
  • Esempi di parametri ma NON iperparametri: coefficiente angolare nella regressione lineare, pesi nella regressione logistica, ecc.
  • Esempi di iperparametri: max_depth, n_estimators, ecc.
Prevedere il CTR con il 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, ...)
Prevedere il CTR con il Machine Learning in Python

Passons à la pratique !

Prevedere il CTR con il Machine Learning in Python

Preparing Video For Download...