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

Predict for new data. #20

Closed
vi3k6i5 opened this issue Sep 19, 2017 · 5 comments
Closed

Predict for new data. #20

vi3k6i5 opened this issue Sep 19, 2017 · 5 comments

Comments

@vi3k6i5
Copy link
Contributor

vi3k6i5 commented Sep 19, 2017

Say I trained the model with

fm.run(train_x, train_y, val_x, val_y)

How do i run prediction for another dataset?

pred_y = fm.run(test_x)

run method expects y_test as input, Which doesn't make sense at all.
run(self, x_train, y_train, x_test, y_test, x_validation_set=None, y_validation_set=None, meta=None)

@jfloff
Copy link
Owner

jfloff commented Sep 19, 2017

  1. Regarding y_test as input:
    libfm uses the test values to output some results regarding its predictions. They are not used when training the model. If I'm not mistaken, you could actually set them to a dummy value and just collect the predictions (just disregard the prediction statistics since those will be wrong). For more info check libfm manual.

  2. Regarding running against a new dataset, at this moment you can't. Its a limitation from libfm itself. You have to train again. See this issue Predict new data without training. #7

Hope it helps,

@jfloff jfloff closed this as completed Sep 19, 2017
@vi3k6i5
Copy link
Contributor Author

vi3k6i5 commented Sep 19, 2017

Thanks :) Please add the same in README maybe. Might help others.

@jfloff
Copy link
Owner

jfloff commented Sep 19, 2017

I'm so busy atm that I can't even breathe!
Feel free to PR that change ;)

@vi3k6i5
Copy link
Contributor Author

vi3k6i5 commented Sep 19, 2017

Done. #21

Will try to make changes for #7 also. Any tips on how I should approach that problem ??

I was thinking of saving the trained model in a file. and keeping the reference object inside the model object. Adding a method named predict and predicting with that model object.

Doesn't seem clean, but it's a quick hack. Let me know.

@jfloff
Copy link
Owner

jfloff commented Sep 20, 2017

The better approach would be something supported from the original libfm repo. But I think that's not going to happen... They even removed support for the save/load model on the MCMC method.

I guess we could try your approach. Just remember to correctly clean temporary files, those can be quite big when dealing with large datasets.

Kudos for tackling this!

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

2 participants