Can models be saved / loaded? #464
-
Hope this is the correct place for this. Once a model has been “trained” (run over a sufficient amount of online data) can it be “saved” (persisted to a file) and subsequently “loaded” (reconstituted from a file with learned data intact) in a subsequent run / process? thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hey! Yes you can! There's an example in the FAQ: >>> from river import ensemble
import pickle
model = ensemble.AdaptiveRandomForestClassifier()
with open('model.pkl', 'wb') as f:
pickle.dump(model, f)
with open('model.pkl', 'rb') as f:
model = pickle.load(f) Each model is unit tested to make sure that it can be pickled. When you load the model, it will be in the exact same state as when you saved it. |
Beta Was this translation helpful? Give feedback.
-
Thanks! (Was that there before and I just missed it? If so apologies!)
jb
… On Feb 3, 2021, at 13:05, Max Halford ***@***.***> wrote:
Hey! Yes you can! There's an example in the FAQ:
>>> from river import ensemble
import pickle
model = ensemble.AdaptiveRandomForestClassifier()
with open('model.pkl', 'wb') as f:
pickle.dump(model, f)
with open('model.pkl', 'rb') as f:
model = pickle.load(f)
Each model is unit tested to make sure that it can be pickled. When you load the model, it will be in the exact same state as when you saved it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Beta Was this translation helpful? Give feedback.
Hey! Yes you can! There's an example in the FAQ:
Each model is unit tested to make sure that it can be pickled. When you load the model, it will be in the exact same state as when you saved it.