Closed muxaulmarin closed 2 years ago
You're not calling the model's correctly with either your A or B option - which is why you're getting different results from what'd you expect
Can you try with:
cosine.recommend(
userid=user_id,
user_items=uim[user_id]
)
You'll need to set the other filtering options too - but where you are going wrong is in setting the userid / user_items parameters - you're passing the wrong userid in option B, and passing the wrong user_items in option A.
I should probably have the cosine model throw an error to highlight this earlier - but I believe that the ALS model would have thrown an error if you had specified either recalculate_use or filter_already_liked_items options (without those, the MF models doesn't need the sparse matrix passed in and ignores the user_items parameter).
I tried showing how to use the recommend API in the tutorial notebook - https://benfred.github.io/implicit/tutorial_lastfm.html#Making-Recommendations
# Get recommendations for the a single user
userid = 12345
ids, scores = model.recommend(userid, user_plays[userid], N=10, filter_already_liked_items=False)
Thx for answer, unfortunately for me it does not solve the problem
Thx for answer, unfortunately for me it does not solve the problem
Sorry to hear that you're still having a problem - let me know if you need any help solving
Hello. I prepared a small reproducible example to better explain the problem
numpy version = 1.23.1 scipy version = 1.8.1 implicit version = 0.6.0
Configure
Create Users2Items matrix
Fit ALS model
Fit Item2Item model
Get recommendations We can get recommendations without using method
.recommend
, for AlternatingLeastSquares it is the multiplication of user factors by product factors, for CosineRecommender it is the multiplication of user interactions by the product similarity matrixNow we will get recommendations using the method
.recommend
in ways A and BWay A was correct for AlternatingLeastSquares
Way B was correct for CosineRecommender
It seems way A should be correct in both models