-
Notifications
You must be signed in to change notification settings - Fork 610
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
model.similar_items but model.similar_users function not found #33
Comments
There is no function call built into the models right now, but it should be easy to add (at least for the ALS code). Calling this function with an AlternatingLeastSquares model should work (basically just taking cosine distance in the user_factors): def similar_users(model, userid, N=10):
# note: recalculating norms per call is maybe not the most efficient
user_norms = np.linalg.norm(model.user_factors, axis=-1)
scores = model.user_factors.dot(model.user_factors[userid]) / user_norms
best = np.argpartition(scores, -N)[-N:]
return sorted(zip(best, scores[best] / user_norms[itemid]), key=lambda x: -x[1]) |
thank you! And this solved my problem. |
for a single user/item pair - the predicted value is just the dot product of the user factors and the item factors: |
Thanks for your reply |
I don't know if I get this right,
but since
related = model.similar_items(itemid,K)
return the best K similar itemID,
how can I find get the best K similar userID list given some userID?
looking forward to your reply
The text was updated successfully, but these errors were encountered: