Loading XGBoost Model: ModuleNotFoundError: No mod

2020-07-14 05:35发布

问题:

I'm having issues loading a pretrained xgboost model using the following code:

xgb_model = pickle.load(open('churnfinalunscaled.pickle.dat', 'rb'))

And when I do that, I get the following error:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-29-31e7f426e19e> in <module>()
----> 1 xgb_model = pickle.load(open('churnfinalunscaled.pickle.dat', 'rb'))

ModuleNotFoundError: No module named 'sklearn.preprocessing._label'

I haven't seen anything online so any help would be much appreciated.

回答1:

I was able to solve my issue. Simply update scikit-learn from 0.21.3 to 0.22.0 seems to solve the issue. Along the way I have to update my pandas version to 0.25.2 as well.

The cue is provided in this link: https://www.gitmemory.com/vruusmann, where it states:

During Scikit-Learn version upgrade from 0.21.X to 0.22.X many modules were renamed (typically, by prepending an underscore character to the module name). For example, sklearn.preprocessing.label.LabelEncoder became sklearn.preprocessing._label.LabelEncoder.