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_rank is slow for all items of a single user #110

Closed
DeoLeung opened this issue Sep 27, 2016 · 4 comments
Closed

predict_rank is slow for all items of a single user #110

DeoLeung opened this issue Sep 27, 2016 · 4 comments

Comments

@DeoLeung
Copy link

I have a model of (30k, 1m) user/item
when I use predict_rank to predict all the ranks of a single user, it gets slow:

interactions = csr_matrix(
          ([1] * item_size, ([user_id] * item_size, item_ids)),
          shape=(user_size, item_size),
          dtype=np.float32)
# this takes very long
model.predict_rank(interactions)
# very fast
model.predict(user_id, item_ids)

isn't the ranks are just the recommended scores' order?
I guess predict_rank do predict for every interaction?

thanks,

@andyluther
Copy link

i believe predict_rank predicts the rank of every item for each user in interactions

@maciejkula
Copy link
Collaborator

maciejkula commented Sep 27, 2016

This method is to be used when you're only evaluating a couple of interactions for every user, as is most common in evaluating models. It is quadratic in the number of nonzero interactions per user, so if you want to evaluate more items than that I suggest you use predict instead.

I updated the docstring to reflect this in #111

@adsk2050
Copy link

adsk2050 commented Nov 2, 2020

This method is to be used when you're only evaluating a couple of interactions for every user, as is most common in evaluating models. It is quadratic in the number of nonzero interactions per user, so if you want to evaluate more items than that I suggest you use predict instead.

I updated the docstring to reflect this in #111

In that case shouldn't the precision_at_k code be made to run on predict instead of predict_rank/predict_ranks? I am asking because precision_at_k is also very slow.

@tinawenzel
Copy link

tinawenzel commented Nov 16, 2020

This method is to be used when you're only evaluating a couple of interactions for every user, as is most common in evaluating models. It is quadratic in the number of nonzero interactions per user, so if you want to evaluate more items than that I suggest you use predict instead.
I updated the docstring to reflect this in #111

In that case shouldn't the precision_at_k code be made to run on predict instead of predict_rank/predict_ranks? I am asking because precision_at_k is also very slow.

@adsk2050 I agree. I tried to replicate prec@k using predict, but using predict results in a lot smaller prec@k scores than predict_rank. See #568.

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

5 participants