XGBoost:fit() 得到了一个意外的关键字参数 'xgb_model'

XGBoost: fit() got an unexpected keyword argument 'xgb_model'

根据文档,应该可以这样写代码:

# Instantiate the model
model = XGBClassifier() 
model.fit(x, y, xgb_model='model.xgb')

但它失败了:

TypeError: fit() got an unexpected keyword argument 'xgb_model'

参考: http://xgboost.readthedocs.io/en/latest/python/python_api.html

xgb_model (str) – file name of stored xgb model or ‘Booster’ instance Xgb model to be loaded before training (allows training continuation).

我错过了什么吗?

xgb_model 参数 was added to the fit() method quite recently(10 月 1 日)。确保安装了最新的 xgboost 版本。