joblib.load and pickle.load error "No attribute 'XGBoostLabelEncoder'"

Viewed 2047

I'm trying to load a XBGClassifier model with joblib and pickle.

When using joblib loaded_model = joblib.load('trained_model.sav') I'm getting the following error: AttributeError: module 'xgboost.compat' has no attribute 'XGBoostLabelEncoder'

And with pickle loaded_model = pickle.load(open('trained_model.sav', 'rb')) I get AttributeError: Can't get attribute 'XGBoostLabelEncoder' on <module 'xgboost.compat' from 'C:\Users\Usuario\Anaconda3\lib\site-packages\xgboost\compat.py'>

I installed xgboost again but it doesn't work, what might be the issue?

1 Answers

Make sure that the xgboost versions in the saved and loaded environments are the same. You need to change the version of xgboost in the environment that you try to load model.

Related