集成法與超參數調整

用 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...