GBDT文档:Early stopping of Gradient Boosting
文章目录
源码分析
有无early stopping的比较
gbes = ensemble.GradientBoostingClassifier(n_estimators=n_estimators,
validation_fraction=0.2,
n_iter_no_change=5, tol=0.01,
random_state=0)
gb = ensemble.GradientBoostingClassifier(n_estimators=n_estimators,
random_state=0)
打开scikit-learn
源码,看到sklearn.ensemble._gb.GradientBoostingClassifier
尝试用Example作为调试入口:examples/ensemble/plot_gradient_boosting_early_stopping.py
尝试失败。Cython和cpp项目就是难搞。
看到他的基类sklearn.ensemble._gb.BaseGradientBoosting#fit
sklearn/ensemble/_gb.py:424
if self.n_iter_no_change is not None:
stratify = y if is_classifier(self) else None
X, X_val, y, y_val, sample_weight, sample_weight_val = (
train_test_split(X, y, sample_weight,
random_state=self.random_state,
test_size=self.validation_fraction,
stratify=stratify))
if is_classifier(self):
if self.