XGBoost入門學習

Practical XGBoost in Python

地址: https://www.bilibili.com/video/av21249915
原視頻博主Github: https://github.com/dmlc/xgboost/tree/master/demo#machine-learning-challenge-winning-solutions
兼有其他博客等參考資料,一併注於文中。
LightGMB之後也要學習一下!

Boosting Algorithm: why works

https://github.com/ParrotPrediction/docker-course-xgboost/blob/master/notebooks/2. Basics/2.1 Boosting - wisdom of the crowd (theory).ipynb

Boosting 概念

Boosting (Freud and Shapire, 1996) - algorithm allowing to fit many weak classifiers to reweighted versions of the training data. Classify final examples by majority voting.

boosting

在使用boosting的時候,數據集中每個樣本都被分配了一個分數,來顯示這個樣本有多難分對(how difficult to classify they are)。在之後的每次iter中,算法就會更加註意哪些之前被分錯(bigger weights)的樣本。

在第一個iter中,數據集中每個樣本的權重是一樣的。

集成的參數是以stage-wise way的方式進行優化的,也就是說我們是在爲下一個classifier算出最優的參數,已經算出來的就會holding fixed。這雖然看起來像是一個limitation,但其實模型正則化的一個很不錯的方法。

Weak Classifier 概念

Weak classifier - an algorithm slightly better than random guessing.

樹作爲基礎算法

雖然每種算法都可以當作是Boosting算法的基礎算法,但是樹的算法有一些很不錯的性質,很適合做爲基礎算法。

優點:

  • 計算的可擴展性(computational scalability)
  • 可以處理缺失值存在的情況
  • 對異常值比較穩健
  • 不需要進行特徵放縮(feature scaling)
  • 可以處理irrelevant inputs
  • 可解釋性(比較少的時候)
  • 可以處理mixed predictors(quantitive and qualitative)

缺點:

  • 不能提取特徵的線性組合
  • small predictive power - 方差大

而boosting的技巧就可以通過取不同樹(where each one is solving the same problem)的平均來減少方差。

GBM, GBT, AdaBoost, XGBoost

四個概念解釋與聯繫

GBM的全稱是Generalized Boosted Models (or Gradient Boosting Machine),是Boosting算法的一種。它的特點是,損失函數是更適合進行優化的損失函數。(We can take advantage of the fact that the loss function can be represented with a form suitable for optimalization (due to the stage-wise additivity).)
GBT(應當就是GBDT?)全稱爲Gradient Boosted Tree, 是GBM的一種。它用決策樹作爲estimator, 損失函數有很多種情形——It can work with different loss functions (regression, classification, risk modeling etc.), evaluate it’s gradient and approximates it with a simple tree (stage-wisely, that minimizes the overall error).
AdaBoost全稱爲Adaptive Boosting, 是GBT的一種特例。它使用的是指數的損失函數。
XGBoost全稱是Extreme Gradient Boosting,它是一個更加正則化版本的Gradient Boosted Tree (GBT)。

AdaBoost算法簡介

AdaBoost是採用了Boosting的技巧,並且把決策樹作爲meta-estimator(元估計器,是由多個獨立的estimator組成的,you can fit any classifier in。
本算法數學上可以解釋爲類似在函數空間上做最速梯度下降。每次迭代中,選擇的 weak classifier 函數其實是當前負梯度方向,而對應的權值則是在此方向使 loss 減少最多的步長(greedy~)。這裏使用的 loss function 是 exponential function,而 GBDT(gradient boost decision tree)推廣到了其他 error function,也可以說 AdaBoost 是一種 GBDT。(本段摘自[參考博客]1)
在這裏插入圖片描述

XGBoost算法簡介

樹的一些相關算法很多都有些正則化的問題,因爲他們允許有很多相似的樹的存在。GBT視圖通過增加一些正則化的參數來解決這個問題,對此我們可以:

  • 控制樹的結構(maximum depth, minimum samples per leaf)
  • 控制學習速率(shrinkage)
  • 通過加入一些隨機性來減小方差(stochastic gradient boosting - using random subsamples of instances and features)

但是更好的正則化解決方法,那就就是XGBoost。XGBoost (extreme gradient boosting) is a more regularized version of Gradient Boosted Trees.

它的優點:

  • good bias-variance (simple-predictive) trade-off “out of the box”
  • 計算速度不錯
  • 作者很樂意接受大家的一些建議,不斷對庫進行一些更新

在這裏插入圖片描述

課程作者注: 更多XGBoost資料可參考

  1. XGBoost Document: https://xgboost.readthedocs.io/en/latest/
  2. XGBoost Presentation: https://www.slideshare.net/ShangxuanZhang/xgboost

待參考博客/視頻

  1. 一位blogger的系列博客
    1)GLM(廣義線性模型)與LR(邏輯迴歸)詳解:
    https://blog.csdn.net/Cdd2xd/article/details/75635688
    2)AdaBoost詳解:
    https://blog.csdn.net/Cdd2xd/article/details/77342350
    3)GBM與GBDT與XGBoost:https://blog.csdn.net/Cdd2xd/article/details/77426622
  2. 課程作者注: 關於GBM,更多的信息請參考視頻:
    https://www.youtube.com/watch?reload=9&v=wPqtzj5VZus&feature=youtu.be
  3. 課程作者注: 更多XGBoost資料可參考
    1)XGBoost Document: https://xgboost.readthedocs.io/en/latest/
    2)XGBoost Presentation: https://www.slideshare.net/ShangxuanZhang/xgboost
  4. 廣泛的XGBoost等相關梳理、入門的博客
    1)Python機器學習之XGBoost從入門到實戰(基本理論說明)
    https://blog.csdn.net/Gerry199102/article/details/78576994
    2)xgboost入門與實戰(原理篇)
    https://blog.csdn.net/sb19931201/article/details/52557382
    3)xgboost:一個純小白的學習歷程
    https://blog.csdn.net/Totoro1745/article/details/53328725
    4)Gradient Tree Boosting (GBM, GBRT, GBDT, MART)算法解析和基於XGBoost/Scikit-learn的實現
    https://blog.csdn.net/yangliuy/article/details/62411509
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章