pyFM
pyFM copied to clipboard
How to save the trained model?
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
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
@YiJingLin is that really worked? the pyfm.pylibfm.FM does not have a write attribute