5
votes

Lets say I build an xgboost model:

bst = xgb.train(param0, dtrain1, num_round, evals=[(dtrain, "training")])

Where:

  • param0 is a set of params to xgb,
  • dtrain1 is a DMatrix ready to be trained
  • num_round is the number of rounds

Then, I save the model to disk:

bst.save_model("xgbmodel")

Later on, I want to reload the model I saved and continue training it with dtrain2

Does anyone have an idea how to do it?

1

1 Answers

14
votes

You don't even have to load the model from the disk and retrain.

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).

Example:

bst = xgb.train(param0, dtrain2, num_round, evals=[(dtrain, "training")], xgb_model='xgbmodel')

Good luck!