为什么 AdaBoost 或 GradientBoosting 与单个估计器的集成给出的值与单个估计器的值不同?

Why does AdaBoost or GradientBoosting ensemble with a single estimator give different values than the single estimator?

我很好奇为什么单估计器 Adaboost“集成”、单估计器梯度提升“集成”和单个决策树给出不同的值。

下面的代码比较了三个模型,它们都使用相同的基础估计器(max_depth = 4 的回归树和基于 mse 的损失。)

  1. 作为裸树模型的基本估计
  2. 使用基本估计器作为原型的单估计器 Adaboost
  3. 使用基本估计器作为原型的单估计器 GBR

提取和检查树表明它们非常不同,即使每个树都应该以相同的方式训练。

from sklearn.datasets import load_diabetes
from sklearn.ensemble import AdaBoostRegressor, GradientBoostingRegressor
from sklearn.tree import DecisionTreeRegressor, export_text

data = load_diabetes()
X = data['data']
y = data['target']

simple_model = DecisionTreeRegressor(max_depth=4)
prototype = DecisionTreeRegressor(max_depth=4)
simple_ada = AdaBoostRegressor(prototype, n_estimators=1)
simple_gbr = GradientBoostingRegressor(max_depth=4, n_estimators=1, criterion='mse')

simple_model.fit(X, y)
simple_ada.fit(X, y)
simple_gbr.fit(X, y)

ada_one = simple_ada.estimators_[0]
gbr_one = simple_gbr.estimators_[0][0]

print(export_text(simple_model))
print(export_text(ada_one))
print(export_text(gbr_one))

AdaBoostRegressor 对其每棵树执行加权 bootstrap 采样(与 AdaBoostClassifier 不同,IIRC 仅使用样本权重来拟合基分类器):source。因此,无法强制 single-tree AdaBoost 回归器匹配单个决策树(我想,如果不手动进行 bootstrap 采样并拟合单个决策树)。


GradientBoostingRegressor 对每个要提升的样本都有一个初始值:

init : estimator or ‘zero’, default=None
An estimator object that is used to compute the initial predictions. init has to provide fit and predict. If ‘zero’, the initial raw predictions are set to zero. By default a DummyEstimator is used, predicting either the average target value (for loss=’squared_error’), or a quantile for the other losses.

因此您的树与 single-estimator-gbm 之间的主要区别在于后者的叶值按平均目标值移动。设置 init='zero' 让我们更接近,但我确实看到在树的更下方选择的拆分存在一些差异。 是由于最佳分割值的关系,可以通过设置一个通用的 random_state 来解决。