Skip to content Skip to sidebar Skip to footer

"typeerror: __cinit__() Takes Exactly 8 Positional Arguments (3 Given)" When Loading Sklearn Pickle

I have a Flask app on pythonanywhere (Python 2.7) that needs to load a pickle file containing a machine learning estimator made with sklearn. with open('pickle.pkl', 'rb') as

Solution 1:

It looks like you are using different versions of sklearn. I.e the version of sklearn that you used to make the model is not the same version installed on the machine that is used to unpickle the model.

I had this exact problem: my local machine was training and pickling random forests using sklearn 0.18 (dev); I had an ec2 instance running sklearn 0.17 (where I was outputting predictions from the unpickled random forest);

>

>> foo_predictor = pickle.load(open('rF_REVENUENext_version2.pkl', 'rb'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/pickle.py", line 1378, inloadreturn Unpickler(file).load()
  File "/usr/lib/python2.7/pickle.py", line 858, inload
    dispatch[key](self)
  File "/usr/lib/python2.7/pickle.py", line 1133, in load_reduce
    value = func(*args)
  File "_tree.pyx", line 1282, in sklearn.tree._tree.Tree.__cinit__ (sklearn/tree/_tree.c:10342)
TypeError: __cinit__() takes exactly 8 positional arguments (3 given)

Post a Comment for ""typeerror: __cinit__() Takes Exactly 8 Positional Arguments (3 Given)" When Loading Sklearn Pickle"