I'm trying to pickle a trained SVM classifier from the Scikit-learn library so that I don't have to train it over and over again. But when I pass the test data to the classifier loaded from the pickle, I get unusually high values for accuracy, f measure, etc. If the test data is passed directly to the classifier which is not pickled, it gives much lower values. I don't understand why pickling and unpickling the classifier object is changing the way it behaves. Can someone please help me out with this?
I'm doing something like this:
from sklearn.externals import joblib
joblib.dump(grid, 'grid_trained.pkl')
Here, grid
is the trained classifier object. When I unpickle it, it acts very different from when it is directly used.
There should not be any difference as @AndreasMueller stated, here's a modified example from http://scikit-learn.org/stable/tutorial/text_analytics/working_with_text_data.html#loading-the-20-newgroups-dataset using
pickle
:It's the same when using
sklearn.externals.joblib
too: