On the link of XGBoost guide:
After training, the model can be saved.
bst.save_model('0001.model')
The model and its feature map can also be dumped to a text file.
# dump model bst.dump_model('dump.raw.txt') # dump model with feature map bst.dump_model('dump.raw.txt', 'featmap.txt')
A saved model can be loaded as follows:
bst = xgb.Booster({'nthread': 4}) # init model bst.load_model('model.bin') # load data
My questions are following.
save_model
& dump_model
? '0001.model'
and 'dump.raw.txt','featmap.txt'
?model.bin
is different from the name to be saved 0001.model
? model_A
and model_B
. I wanted to save both models for future use. Which save
& load
function should I use? Could you help show the clear process?Both functions save_model
and dump_model
save the model, the difference is that in dump_model
you can save feature name and save tree in text format.
The load_model
will work with model from save_model
. The model from dump_model
can be used for example with xgbfi.
During loading the model, you need to specify the path where your models is saved. In the example bst.load_model("model.bin")
model is loaded from file model.bin
- it is just a name of file with model. Good luck!