Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to save the trained model? #26

Open
Darinyazanr opened this issue Aug 23, 2017 · 2 comments
Open

How to save the trained model? #26

Darinyazanr opened this issue Aug 23, 2017 · 2 comments

Comments

@Darinyazanr
Copy link

Darinyazanr commented Aug 23, 2017

I can't find the way for save the model?Could someone help to solve this? thx
now I can run like this:
fm = pylibfm.FM()
fm.fit(X,y)
fm.predict(v.transform({"user": "1", "item": "10", "age": 24}))
but can't to find the way to save the model

@YiJingLin
Copy link

Hi @Darinyazanr,
maybe "pickle" library can help you
code as follows:

import pickle

fm = pylibfm.FM()
fm.fit(X,y)

with open('fm_model.pkl', 'wb') as f:
    pickle.dump(fm, f)
del fm # make sure variable is empty 
with open('fm_model.pkl', 'rb') as f:
    fm = pickle.load(f)

fm.predict(v.transform({"user": "1", "item": "10", "age": 24}))

after that
you'll get a file named "fm_model.pkl" under the same directory

@fooSynaptic
Copy link

@YiJingLin is that really worked? the pyfm.pylibfm.FM does not have a write attribute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants