Python版本:3.5 // xgboost版本:0.7.post3
大家好,
我正在尝试使用Python中的xgboost模块实现增量学习,其中我的目标变量是二进制的。我认为我应该设置参数"process_type": "update"。问题是我遇到了一个错误,我无法解决。在这里,我提供了一个使用来自sklearn的乳腺癌数据集的代码示例,以便大家可以尝试一下。有人知道如何防止发生以下错误吗?
from sklearn import datasets
import xgboost
X_all = datasets.load_breast_cancer().data
y_all = datasets.load_breast_cancer().target
X_first_half = X_all[0:280,:]
X_second_half = X_all[280:,:]
y_first_half = y_all[0:280]
y_second_half = y_all[280:]
model1 = xgboost \
.train({'objective': 'binary:logistic'},
dtrain=xgboost.DMatrix(X_first_half, y_first_half),
xgb_model=None)
model2 = xgboost \
.train({'objective': 'binary:logistic',
'process_type': 'update',
'update': 'refresh',
'refresh_leaf': True},
dtrain=xgboost.DMatrix(X_second_half, y_second_half),
xgb_model=model1)
我收到的错误信息是:
XGBoostError: b'[15:03:03] src/tree/updater_colmaker.cc:118:
Check failed: tree.param.num_nodes == tree.param.num_roots (19 vs. 1)
ColMaker: can only grow new tree\n\nStack trace returned 1 entries:\n[bt] (0)
update
应该改为updater
。 - Fortunato