什么是Boosting?

使用 XGBoost 的极端梯度提升

Sergey Fogelson

Head of Data Science, TelevisaUnivision

Boosting 概览

  • 不是某个特定的机器学习算法
  • 可应用于一组机器学习模型的概念
    • "元算法"
  • 集成元算法:将多个弱学习器转化为强学习器
使用 XGBoost 的极端梯度提升

弱学习器与强学习器

  • 弱学习器:性能略优于随机的算法
    • 例:预测略高于50%的决策树
  • Boosting 将一组弱学习器转化为强学习器
  • 强学习器:可通过调参获得良好表现的算法
使用 XGBoost 的极端梯度提升

Boosting 的实现方式

  • 在数据子集上迭代训练一组弱模型
  • 按各弱学习器的表现为其预测加权
  • 合并加权预测得到单一加权预测
  • …其效果明显优于各单独预测!
使用 XGBoost 的极端梯度提升

Boosting 示例

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

用交叉验证评估模型

  • 交叉验证:评估模型在未见数据上性能的稳健方法
  • 在训练数据上生成多个不重叠的训练/测试划分
  • 汇报所有划分上测试集表现的平均值
使用 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...