benfred / implicit

Fast Python Collaborative Filtering for Implicit Feedback Datasets
https://benfred.github.io/implicit/
MIT License
3.57k stars 612 forks source link

Check user_items is a CSR matrix in recommend #504

Closed benfred closed 2 years ago

benfred commented 2 years ago

If user_items isn't a CSR matrix in the recommend call then wrong results will get returned with filter_already_liked_items or recalculate_user options.

Closes #365

nikhilsingh13 commented 2 years ago

I found an issue with this merge.

For example: if userid = 11518 and user_items.shape[0] = 82302. In that case user_count = 1 if np.isscalar(userid) else len(userid) will give user_count=1

Now, in the next line,

if user_items.shape[0] != user_count:
                raise ValueError("user_items must contain 1 row for every user in userids")

user_items.shape[0] will not match the user_count and will keep on raising the ValueError.

Kindly suggest if I am missing something?