为什么我使用scikitlearn的GradientBoostingRegressor从相同的输入中得到不同的输出?

2024-05-13 01:09:25 发布

您现在位置:Python中文网/ 问答频道 /正文

例如:

params = {'n_estimators': 200, "max_depth": 4, 'subsample': 1, 'learning_rate': 0.1}
boost = ensemble.GradientBoostingRegressor(**params)
ghostBoost = ensemble.GradientBoostingRegressor(**params)

...

boost.fit(x, y)
ghostBoost.fit(x, y)

...

predictionA = boost.predict(features)
predictionB = ghostBoost.predict(features)

boostghostBoost完全相同,但是predictionA不等于{},为什么会这样?在


Tags: rateparamspredictmaxfitlearningfeaturesensemble
1条回答
网友
1楼 · 发布于 2024-05-13 01:09:25

尝试将两个模型的random_state构造函数参数修复为相同的值。决策树构建过程是随机的,因为每个节点考虑从可用特性中随机抽取max_features有替换没有替换)。在

编辑:特征采样不进行替换。当max_features=None(默认值)时,所有特征都会被计算,但是,当max_depth不是{}时,顺序会发生变化,并且目标变量具有非唯一值,从而导致最佳特征拆分。在

相关问题 更多 >