集成与超参数调优

用 Python 预测 CTR 的机器学习实战

Kevin Huo

Instructor

集成方法

自助聚合示例

  • Bagging:为不同模型抽取随机样本,分别训练,再进行集成。
用 Python 预测 CTR 的机器学习实战

随机森林

clf = RandomForestClassifier()
print(clf)
RandomForestClassifier(
  bootstrap=True,
  ...
  max_depth = 10,
  ...
  n_estimators = 100,
  ...)
用 Python 预测 CTR 的机器学习实战

超参数调优

  • 超参数:训练前设定、外部控制的参数
  • 参数但非超参数示例:线性回归的斜率系数、逻辑回归的权重等。
  • 超参数示例:max_depthn_estimators 等。
用 Python 预测 CTR 的机器学习实战

网格搜索

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, ...)
用 Python 预测 CTR 的机器学习实战

让我们来练习!

用 Python 预测 CTR 的机器学习实战

Preparing Video For Download...