加载XGBoost模型:ModuleNotFoundError:没有名为"sklearn.preprocessing._label"的模块 [英] Loading XGBoost Model: ModuleNotFoundError: No module named 'sklearn.preprocessing._label'

查看:2717
本文介绍了加载XGBoost模型:ModuleNotFoundError:没有名为"sklearn.preprocessing._label"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码加载预训练的xgboost模型时遇到问题:

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.

推荐答案

我能够解决我的问题.只需将scikit-learn从0.21.3更新到0.22.0似乎可以解决此问题.一路上,我还必须将pandas版本也更新为0.25.2.

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.

此链接中提供了提示: https://www.gitmemory.com/vruusmann ,其中指出:

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

在Scikit-Learn版本从0.21.X升级到0.22.X的过程中,许多模块被重命名(通常在模块名称前添加下划线字符).例如,sklearn.preprocessing.label.LabelEncoder变为sklearn.preprocessing._label.LabelEncoder.

这篇关于加载XGBoost模型:ModuleNotFoundError:没有名为"sklearn.preprocessing._label"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆