Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ グラディエントブースティング:理論と実装 | セクション
木構造アンサンブル手法

bookグラディエントブースティング:理論と実装

メニューを表示するにはスワイプしてください

勾配ブースティングは、弱学習器(通常は決定木)を逐次的に学習させるアンサンブル手法であり、それぞれの新しいモデルは現在の予測値に対する損失関数の勾配に適合します。

AdaBoostがサンプルの重みを調整するのとは異なり、勾配ブースティングは前のモデルの残差に弱学習器を直接適合させ、選択した損失関数を段階的に最小化します。

数学的直感

各モデルは前段階の残差から学習します:

ri(t)=L(yi,F(xi))F(xi)r_i^{(t)} = -\frac{\partial L(y_i, F(x_i))}{\partial F(x_i)}

次に、新しいモデル $h_t(x)$ をこれらの残差に適合させ、アンサンブルは次のように更新されます:

Ft+1(x)=Ft(x)+η,ht(x)F_{t+1}(x) = F_t(x) + \eta , h_t(x)

ここで:

  • LL — 損失関数(例:MSEまたは対数損失)、
  • η\eta — 各木の寄与度を制御する学習率。
1234567891011121314151617181920212223242526272829303132333435
from sklearn.datasets import load_breast_cancer from sklearn.model_selection import train_test_split from sklearn.ensemble import GradientBoostingClassifier from sklearn.metrics import accuracy_score import matplotlib.pyplot as plt # Load dataset X, y = load_breast_cancer(return_X_y=True) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42) # Initialize and train the model gb = GradientBoostingClassifier( n_estimators=100, learning_rate=0.1, max_depth=3, random_state=42 ) gb.fit(X_train, y_train) # Evaluate y_pred = gb.predict(X_test) # Compute staged accuracy manually (works in all sklearn versions) test_accuracy = [] for y_stage_pred in gb.staged_predict(X_test): acc = accuracy_score(y_test, y_stage_pred) test_accuracy.append(acc) # Plot staged accuracy plt.plot(range(1, len(test_accuracy) + 1), test_accuracy) plt.xlabel("Number of Trees") plt.ylabel("Test Accuracy") plt.title(f"Gradient Boosting Learning Progression (Accuracy: {accuracy_score(y_test, y_pred):.3f})") plt.grid(True) plt.show()
copy
question mark

勾配ブースティングにおける勾配の役割を最もよく表している説明はどれですか?

正しい答えを選んでください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  10

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 1.  10
some-alt