부스팅이란?

XGBoost로 익히는 Extreme Gradient Boosting

Sergey Fogelson

Head of Data Science, TelevisaUnivision

부스팅 개요

  • 특정 머신러닝 알고리즘이 아님
  • 다양한 머신러닝 모델에 적용 가능한 개념
    • "메타 알고리즘"
  • 다수의 약한 학습기를 강한 학습기로 변환하는 앙상블 메타 알고리즘
XGBoost로 익히는 Extreme Gradient Boosting

약한 학습기와 강한 학습기

  • 약한 학습기: 무작위 추측보다 약간 나은 ML 알고리즘
    • 예시: 예측 정확도가 50%를 약간 넘는 결정 트리
  • 부스팅은 약한 학습기 집합을 강한 학습기로 변환
  • 강한 학습기: 튜닝을 통해 높은 성능을 달성할 수 있는 알고리즘
XGBoost로 익히는 Extreme Gradient Boosting

부스팅의 작동 방식

  • 데이터 부분집합에서 약한 모델을 반복적으로 학습
  • 각 약한 학습기의 성능에 따라 예측에 가중치 부여
  • 가중치가 적용된 예측을 결합하여 단일 예측 생성
  • ... 개별 예측보다 훨씬 우수한 결과!
XGBoost로 익히는 Extreme Gradient Boosting

부스팅 예시

1 https://xgboost.readthedocs.io/en/latest/model.html
XGBoost로 익히는 Extreme Gradient Boosting

교차 검증을 통한 모델 평가

  • 교차 검증: 미학습 데이터에 대한 모델 성능을 추정하는 강력한 방법
  • 학습 데이터에서 겹치지 않는 다수의 학습/테스트 분할을 생성
  • 모든 데이터 분할에 걸친 평균 테스트 성능을 보고
XGBoost로 익히는 Extreme Gradient Boosting

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로 익히는 Extreme Gradient Boosting

연습해 봅시다!

XGBoost로 익히는 Extreme Gradient Boosting

Preparing Video For Download...