I am trying to save and load the scikit-learn model, but having problems saving and loading in different versions of python. Here is what I tried:
Using pickle to save the model in python3 and deserialize in python2. This works for some models like LR, SVM, but it does not work for KNN.
>>> pickle.load(open("inPy3.pkl", 'rb'))
Also, I tried serializing and deserializing in json using jsonpickle, but getting the following error.
data = jsonpickle.encode(lr) #lr = logisticRegression Model jsonpickle.decode(data) AttributeError: 'dict' object has no attribute '__name__'
In addition, I want to know if there is any utility that I can use to serialize and deserialize objects of the scikit-learn model for a human-readable format (json, xml, protobuf, etc.).
source share