0

I have created an sklearn model that I would like to imbed into my nodejs web app. I have created the model with python3 and packaged it into a pkl file with joblib.

from sklearn.externals import joblib
joblib.dump(clf, 'RandomForest_jul30.pkl', protocol=2)

I am using npm package "child_process" to run a python script which I will load the data into and unpackage the pkl file with joblib.loads although it throws the error:

ValueError: unsupported pickle protocol: 3

I have tried to change which python version I am using although I still get similar errors or version related errors.

Edit: when run with python 3 the error is:

/usr/lib/python3/dist-packages/sklearn/base.py:315: UserWarning: Trying to unpickle estimator DecisionTreeClassifier from version 0.18.1 when using version 0.18. This might lead to breaking code or invalid results. Use at your own risk.
  UserWarning) . . . KeyError: 2

1 Answers1

0

Try using cPickle

import cPickle as pkl
pkl.dump(clf,open('Clf.clf','wb+'))
Mohamed Emad
  • 123
  • 1
  • 14