-
Notifications
You must be signed in to change notification settings - Fork 615
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
Add a recommend method for making customised recommendation for users? #5
Comments
I agree that adding something like this to the library makes a ton of sense. I'll see about adding this when I have some time. In the meantime: def predict(item_factors, user_factors, userid, N=10):
scores = item_factors.dot(user_factors[userid])
best = numpy.argpartition(scores, -N)[-N:]
return sorted(zip(best, scores[best]), key=lambda x: -x[1]) should return the top N artists for userid. |
Hi Benfred, |
I'm pretty sure that the code correctly implements the paper. Pui is a binary value - its 1 if the user has interacted with an item and 0 otherwise. The Cui confidence matrix I'm passing in is a sparse matrix, with entries for only the positive preferences (Pui = 1). So iterating over the nonzeros of Cui means that Pui is 1 . If I listed it out explicitly the code would be: for i, confidence in nonzeros(Cui, u):
factor = Y[i]
A += (confidence - 1) * np.outer(factor, factor)
Pui = 1
b += confidence * factor * Pui But since its just adding in a multiply by 1 - I don't need to do this. I made a note about this in the cython version: https://github.com/benfred/implicit/blob/master/implicit/_implicit.pyx#L89 but didn't bother in the python version Also Cui can be set to any weighting scheme you want - it doesn't affect how the solution is derived (since its a constant wrt to the params we're minimizing). The original paper suggests using the log of the play counts. |
@vnnw the last commit refactors this to a class, with a recommend method for generating personalized recommendations: 8c18f16#diff-604d1b48a6ae71b2cc39b27249942f12R84 In addition to the snippet I posted above, this also filters out the users own liked items. |
@benfred Just to make sure I get this right, when you say "Cui can be set to any weighting scheme you want", we're still assuming here that "empty" entries in the confidence matrix have a value set to exactly 1, right ? |
To compute similar artists is great, but making customised recommendation for each user based on his or her listening history could be better?
The text was updated successfully, but these errors were encountered: