Loading XGBoost Model: ModuleNotFoundError: No module named 'sklearn.preprocessing._label'

馋奶兔 提交于 2020-05-11 07:48:10

问题


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.



来源:https://stackoverflow.com/questions/59493070/loading-xgboost-model-modulenotfounderror-no-module-named-sklearn-preprocessi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!