AdaBoost

Python으로 배우는 트리 기반 Machine Learning

Elie Kawerk

Data Scientist

부스팅

  • 부스팅(Boosting): 여러 약한 학습자를 결합해 강한 학습자를 만드는 앙상블 방법.

  • 약한 학습자: 무작위 추정보다 약간 더 나은 모델.

  • 약한 학습자 예: 결정 그루터기(최대 깊이 1인 CART).

Python으로 배우는 트리 기반 Machine Learning

부스팅

  • 예측기를 순차적으로 학습.

  • 각 예측기는 이전 모델의 오류를 보정.

  • 대표적 부스팅 방법:

    • AdaBoost,

    • 그래디언트 부스팅.

Python으로 배우는 트리 기반 Machine Learning

Adaboost

  • Adaptive Boosting의 약자.

  • 각 예측기는 이전 모델이 틀린 사례에 더 큰 가중을 둠.

  • 학습 샘플 가중치를 조정하여 달성.

  • 각 예측기에 계수 $\alpha$ 부여.

  • $\alpha$는 학습 오차에 따라 결정.

Python으로 배우는 트리 기반 Machine Learning

AdaBoost: 학습

ada-train

Python으로 배우는 트리 기반 Machine Learning

학습률

학습률: $0 < \eta \leq 1$ ada-lr

Python으로 배우는 트리 기반 Machine Learning

AdaBoost: 예측

  • 분류:

    • 가중 다수결.
    • sklearn: AdaBoostClassifier.
  • 회귀:

    • 가중 평균.
    • sklearn: AdaBoostRegressor.
Python으로 배우는 트리 기반 Machine Learning

sklearn에서의 AdaBoost 분류 (유방암 데이터셋)

# Import models and utility functions
from sklearn.ensemble import AdaBoostClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import roc_auc_score
from sklearn.model_selection import train_test_split

# Set seed for reproducibility
SEED = 1

# Split data into 70% train and 30% test
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3,
                                                    stratify=y,
                                                    random_state=SEED)
Python으로 배우는 트리 기반 Machine Learning
# Instantiate a classification-tree 'dt'
dt = DecisionTreeClassifier(max_depth=1, random_state=SEED)

# Instantiate an AdaBoost classifier 'adab_clf' adb_clf = AdaBoostClassifier(base_estimator=dt, n_estimators=100)
# Fit 'adb_clf' to the training set adb_clf.fit(X_train, y_train) # Predict the test set probabilities of positive class y_pred_proba = adb_clf.predict_proba(X_test)[:,1]
# Evaluate test-set roc_auc_score adb_clf_roc_auc_score = roc_auc_score(y_test, y_pred_proba)
Python으로 배우는 트리 기반 Machine Learning

sklearn에서의 AdaBoost 분류 (유방암 데이터셋)

# Print adb_clf_roc_auc_score
print('ROC AUC score: {:.2f}'.format(adb_clf_roc_auc_score)) 
ROC AUC score: 0.99
Python으로 배우는 트리 기반 Machine Learning

연습해 봅시다!

Python으로 배우는 트리 기반 Machine Learning

Preparing Video For Download...