什麼是 Boosting?

使用 XGBoost 的極端梯度提升

Sergey Fogelson

Head of Data Science, TelevisaUnivision

Boosting 概觀

  • 不是特定的機器學習演算法
  • 可套用在一組機器學習模型的概念
    • 「後設演算法」
  • 集成式後設演算法,將多個弱學習器轉為強學習器
使用 XGBoost 的極端梯度提升

弱學習器與強學習器

  • 弱學習器:只比隨機好一點的 ML 演算法
    • 例:預測僅略優於 50% 的決策樹
  • Boosting 將多個弱學習器組合成一個強學習器
  • 強學習器:可調整以達到良好效能的任何演算法
使用 XGBoost 的極端梯度提升

Boosting 如何運作

  • 反覆在資料的子集上學習一組弱模型
  • 依各弱學習器的表現為其預測加權
  • 合併加權後的預測,得到單一加權預測
  • ……通常遠優於各個單獨預測!
使用 XGBoost 的極端梯度提升

Boosting 範例

1 https://xgboost.readthedocs.io/en/latest/model.html
使用 XGBoost 的極端梯度提升

用交叉驗證評估模型

  • 交叉驗證:評估模型在未見資料上表現的穩健方法
  • 在訓練資料上產生多個不重疊的 train/test 切分
  • 回報所有切分的測試集平均表現
使用 XGBoost 的極端梯度提升

XGBoost 的交叉驗證範例

import xgboost as xgb
import pandas as pd

churn_data = pd.read_csv("classification_data.csv")
churn_dmatrix = xgb.DMatrix(data=churn_data.iloc[:,:-1], label=churn_data.month_5_still_here)
params={"objective":"binary:logistic","max_depth":4}
cv_results = xgb.cv(dtrain=churn_dmatrix, params=params, nfold=4, num_boost_round=10, metrics="error", as_pandas=True)
print("Accuracy: %f" %((1-cv_results["test-error-mean"]).iloc[-1]))
Accuracy: 0.88315
使用 XGBoost 的極端梯度提升

一起來練習吧!

使用 XGBoost 的極端梯度提升

Preparing Video For Download...