Conjuntos (ensembles) e ajuste de hiperparâmetros

Prevendo CTR com Machine Learning em Python

Kevin Huo

Instructor

Métodos de ensemble

Exemplo de bootstrap aggregation

  • Bagging: amostras aleatórias para modelos diferentes; cada modelo é treinado e depois combinado.
Prevendo CTR com Machine Learning em Python

Florestas aleatórias

clf = RandomForestClassifier()
print(clf)
RandomForestClassifier(
  bootstrap=True,
  ...
  max_depth = 10,
  ...
  n_estimators = 100,
  ...)
Prevendo CTR com Machine Learning em Python

Ajuste de hiperparâmetros

  • Hiperparâmetro: definido antes do treino e externo ao modelo
  • Exemplos de parâmetros, mas NÃO hiperparâmetros: coeficiente angular na regressão linear, pesos na regressão logística etc.
  • Exemplos de hiperparâmetros: max_depth, n_estimators etc.
Prevendo CTR com Machine Learning em Python

Busca em grade

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, ...)
Prevendo CTR com Machine Learning em Python

Vamos praticar!

Prevendo CTR com Machine Learning em Python

Preparing Video For Download...