Boosting คืออะไร?

Extreme Gradient Boosting with XGBoost

Sergey Fogelson

Head of Data Science, TelevisaUnivision

ภาพรวมของ Boosting

  • ไม่ใช่อัลกอริทึม machine learning เฉพาะเจาะจง
  • แนวคิดที่ใช้ได้กับกลุ่มโมเดล machine learning
    • "Meta-algorithm"
  • Ensemble meta-algorithm ที่แปลง weak learner หลายตัวให้เป็น strong learner
Extreme Gradient Boosting with XGBoost

Weak learner และ Strong learner

  • Weak learner: อัลกอริทึม ML ที่ทำนายได้ดีกว่าการเดาสุ่มเพียงเล็กน้อย
    • ตัวอย่าง: Decision tree ที่ทำนายได้แม่นยำกว่า 50% เล็กน้อย
  • Boosting แปลงกลุ่ม weak learner ให้เป็น strong learner
  • Strong learner: อัลกอริทึมที่ปรับแต่งให้ได้ประสิทธิภาพดีได้
Extreme Gradient Boosting with XGBoost

วิธีการทำงานของ Boosting

  • เรียนรู้โมเดล weak model ชุดหนึ่งแบบวนซ้ำบนข้อมูลส่วนย่อย
  • กำหนดน้ำหนักให้แต่ละการทำนายตามประสิทธิภาพของ weak learner
  • รวมการทำนายที่มีน้ำหนักเข้าด้วยกันเป็นการทำนายเดียว
  • ... ที่แม่นยำกว่าการทำนายแต่ละตัวมาก!
Extreme Gradient Boosting with XGBoost

ตัวอย่าง Boosting

1 https://xgboost.readthedocs.io/en/latest/model.html
Extreme Gradient Boosting with XGBoost

การประเมินโมเดลด้วย Cross-validation

  • Cross-validation: วิธีที่เชื่อถือได้สำหรับประเมินประสิทธิภาพของโมเดลบนข้อมูลใหม่
  • สร้างชุด train/test ที่ไม่ทับซ้อนกันหลายชุดจากข้อมูล training
  • รายงานค่าเฉลี่ยประสิทธิภาพของ test set จากทุก data split
Extreme Gradient Boosting with XGBoost

ตัวอย่าง Cross-validation ใน 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
Extreme Gradient Boosting with XGBoost

มาฝึกกันเถอะ!

Extreme Gradient Boosting with XGBoost

Preparing Video For Download...