0 votes
1 view
in Machine Learning by (17.4k points)

On the link of XGBoost guide,

The model can be saved. 

bst.save_model('0001.model')

The model and its feature map can also be dumped to a text file.

bst.dump_model('dump.raw.txt') # dump model

bst.dump_model('dump.raw.txt','featmap.txt')# dump model with feature map

A saved model can be loaded as follows: 

bst = xgb.Booster({'nthread':4}) #init model

bst.load_model("model.bin") # load data

My question is :

what's the difference between save_model & dump_model?

what's the difference between saving '0001.model' and 'dump.raw.txt','featmap.txt'?

why the model name for loading model.bin is different from the name to be saved 0001.model?

Suppose that I trained two models 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?

1 Answer

0 votes
by (33.2k points)

Both the functions, you are using in your code, save_model, and dump_model are used to save the model, but the major difference is that in dump_model you can save feature name and save a tree in text format.

The load_model will work with a model from save_model. The model from dump_model can be used with xgbfi.

During loading the model, you need to specify the path where your models are saved. In the example bst.load_model("model.bin") model is loaded from file model.bin, it is the name of a file with the model.

Hope this answer helps.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...