AdaBoost

Pythonで学ぶ木ベースのMachine Learning

Elie Kawerk

Data Scientist

ブースティング

  • ブースティング: 複数の弱学習器を組み合わせて強学習器を構成するアンサンブル手法。

  • 弱学習器: ランダムな推測よりわずかに精度の高いモデル。

  • 弱学習器の例: 決定木ストップ(最大深さ1のCART)。

Pythonで学ぶ木ベースのMachine Learning

ブースティング

  • 予測器を順番に学習させるアンサンブル手法。

  • 各予測器は前の予測器の誤りを修正しようとする。

  • 代表的なブースティング手法:

    • AdaBoost、

    • 勾配ブースティング。

Pythonで学ぶ木ベースのMachine Learning

Adaboost

  • Adaptive Boostingの略。

  • 各予測器は、前の予測器が誤分類したインスタンスに注目する。

  • 学習インスタンスの重みを変更することで実現する。

  • 各予測器には係数 $\alpha$ が割り当てられる。

  • $\alpha$ は予測器の学習誤差に依存する。

Pythonで学ぶ木ベースのMachine Learning

AdaBoost: 学習

AdaBoostの学習

Pythonで学ぶ木ベースのMachine Learning

学習率

学習率: $0 < \eta \leq 1$ AdaBoostの学習率

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...