COM6018 Data Science with Python
Saving and loading a model with pickle
pickle
is a standard Python library for saving and loading Python objects to disk.
If we have a model called model
we can save it to disk with,
import pickle
pickle.dump(model, open('model.pkl', 'wb'))
Then we can load the model later with,
import pickle
model = pickle.load(open('model.pkl', 'rb'))