Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the pickle to save sklearn model

I want to dump and load my Sklearn trained model using Pickle. How to do that?

like image 969
Chittal Avatar asked Feb 26 '19 06:02

Chittal


People also ask

Can you save a Sklearn model?

You can save and load the model using the pickle operation to serialize your machine learning algorithms and save the serialized format to a file. Hope it helps!


1 Answers

Save:

with open("model.pkl", "wb") as f:
    pickle.dump(model, f)

Load:

with open("model.pkl", "rb") as f:
    model = pickle.load(f)
like image 103
Mykola Zotko Avatar answered Oct 11 '22 03:10

Mykola Zotko