My machine has 16G RAM and the training program uses memory up to 2.6G.
But when I want to save the classifier (trained using sklearn.svm.SVC from a large dataset) as pickle file, it consumes too much memory that my machine cannot give. Eager to know any alternative approaches to save an classifier.
I've tried:
pickleandcPickle- Dump as
worwb - Set
fast = True
Neither of them work, always raise a MemoryError. Occasionally the file was saved, but loading it causes ValueError: insecure string pickle.
Thank you in advance!
Update
Thank you all. I didn't try joblib, it works after setting protocol=2.
insecure string pickleerror, I'm usingwithto open the file and actually that program is closed before reading.joblib.dump, it should be smarter about large NumPy arrays than standard pickle.joblib.dump(model,file,compress=3)The scikit-learn model is a random forest with ~thousands of trees. I will try withcompress=2