How to save fitted model?
Closed this issue · 3 comments
Hi!
Thanks a lot for maintaining this great library! It is really convenient and elegant.
I wonder if it is possible to save fitted model as a file?
Hi,
Thanks a lot for maintaining this great library! It is really convenient and elegant.
Thank you!
I wonder if it is possible to save fitted model as a file?
Python pickle works quite well for models that have to be stored only temporarily on a disk:
In [2]: %run examples/plot_estimate_gmm.py
...
In [3]: gmm
Out[3]: <gmr.gmm.GMM at 0x7f07316197d0>
In [4]: import pickle
In [5]: pickle.dump(gmm, open("file", "wb"))
In [6]: gmm2 = pickle.load(open("file", "rb"))
In [7]: gmm2
Out[7]: <gmr.gmm.GMM at 0x7f07213122d0>
If you want to archive your model for a longer time and have a representation that is independent of the underlyin library I would recommend to save the attributes GMM.priors, GMM.means, GMM.covariances
in a format that you think is best suited for this. They are all pure numpy arrays, so this shouldn't be too difficult. There is no other information required to reconstruct the model.
@nikolai-neustroev I'll probably add this answer to the readme. Does it work for you?
@AlexanderFabisch yes, sure. thanks for help!