python xgboost 继续对现有模型进行训练 [英] python xgboost continue training on existing model
本文介绍了python xgboost 继续对现有模型进行训练的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我构建了一个 xgboost 模型:
Lets say I build an xgboost model:
bst = xgb.train(param0, dtrain1, num_round, evals=[(dtrain, "training")])
地点:
- param0 是 xgb 的一组参数,
- dtrain1 是一个可以训练的 DMatrix
- num_round 是回合数
然后,我将模型保存到磁盘:
Then, I save the model to disk:
bst.save_model("xgbmodel")
稍后,我想重新加载我保存的模型并继续用 dtrain2 训练它
Later on, I want to reload the model I saved and continue training it with dtrain2
有人知道怎么做吗?
推荐答案
您甚至不必从磁盘加载模型并重新训练.
You don't even have to load the model from the disk and retrain.
您需要做的只是带有附加参数的相同 xgb.train
命令:xgb_model=(您在问题中保存的 xgboost 模型完整路径名或 Booster 对象).
All you need to do is the same xgb.train
command with additional parameter: xgb_model= (either xgboost model full path name you've saved like in the question or a Booster object).
示例:
bst = xgb.train(param0, dtrain2, num_round, evals=[(dtrain, "training")], xgb_model='xgbmodel')
祝你好运!
这篇关于python xgboost 继续对现有模型进行训练的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文