0
votes

I have trained a XGBoost model during version 0.6 using their sklearn api, so the classifier is of class XGBClassifier(). I have saved that in pickle format.

However, recently I need to move my whole environment to Python 3.6, and along with an updated version of XGBoost 1.0.

I've tried following their guide on loading/saving model (https://xgboost.readthedocs.io/en/latest/tutorials/saving_model.html) but it seems like the old XGBClassifer model doesn't have any of those methods.

What do I do with this trained XGBClassifier() object so I can convert it to be loadable in XGBoost 1.0?

tldr; I have a trained pickled XGB model from version 0.6 using their sklearn api (XGBClassifier()), how do I convert it into a newer version so XGBoost 1.0 can open it?

1

1 Answers

0
votes

Just found the solution.

So for old sklearn api XGBClassifier, you can save the model in binary format. So you load the pickle normally then you call the hidden booster object and call save_model:

clf = pkl.load(model,'rb') clf._booster.save_model('clf.model')

Then in the updated XGBoost 1.0 envirnment, you can do this:

clf = xgb.XGBoostClassifier() clf.load_model('clf.model')

That's it!