简体   繁体   English

sklearn.externals.joblib无法加载pkl文件

[英]sklearn.externals.joblib does not load pkl file

I inherited some code from a coworker who left my company, and I noticed that an email open predictor he wrote hasn't run in a few weeks. 我从一个离开我公司的同事那里继承了一些代码,我注意到他写的一封电子邮件公开预测变量已经有几周没有运行了。 So, I tried to run it. 因此,我尝试运行它。 It got to this line: 到达这一行:

clf_predict = joblib.load(os.path.join(data_dir,'trained_random_forest.pkl'))

And the result was this: 结果是:

File "/usr/local/lib/python2.7/distpackages/sklearn/externals/joblib/numpy_pickle.py", line 425, in load
obj = unpickler.load()
File "/usr/lib/python2.7/pickle.py", line 858, in load dispatch[key](self)
File "/usr/lib/python2.7/pickle.py", line 1133, in load_reduce
value = func(*args)
File "sklearn/tree/_tree.pyx", line 923, in sklearn.tree._tree.Splitter.__cinit__ (sklearn/tree/_tree.c:8329)
TypeError: __cinit__() takes exactly 5 positional arguments (4 given)

The syntax for the load looks right to me from what I've seen in the documentation. 根据我在文档中看到的内容,加载的语法对我而言似乎正确。 Therefore, my initial theory is that maybe scikit-learn was upgraded and can't read the current pickle file (which is a few months old at this point). 因此,我的最初理论是,也许scikit-learn已升级,并且无法读取当前的pickle文件(此文件已有几个月的历史了)。 However, I don't know for sure that it was upgraded, and I'm pretty new to working with sklearn, so I don't know if that would pose a problem. 但是,我不确定它是否已升级,并且我对使用sklearn很陌生,所以我不知道这是否会带来问题。 Appreciate any pointers you can give 感谢您可以提供的任何指导

Assuming that it worked for your co-worker and your problem is due to an sklearn upgrade. 假设它对您的同事有用,而您的问题是由于sklearn升级而引起的。 The extra argument to the Splitter init was introduced in this commit . 此提交中引入了对Splitter init的额外参数。 You could try loading the pkl file in an earlier version of sklearn and take it from there. 您可以尝试在早期版本的sklearn中加载pkl文件,然后从那里获取文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM