Issue
I want to dump and load my Sklearn trained model using Pickle. How to do that?
Solution
Save:
with open("model.pkl", "wb") as f:
pickle.dump(model, f)
Load:
with open("model.pkl", "rb") as f:
model = pickle.load(f)
In the specific case of scikit-learn, it may be better to use joblib’s replacement of pickle (dump & load), which is more efficient on objects that carry large numpy arrays internally as is often the case for fitted scikit-learn estimators:
Save:
joblib.dump(model, "model.joblib")
Load:
model = joblib.load("model.joblib")
Answered By - Mykola Zotko
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.