implicit icon indicating copy to clipboard operation
implicit copied to clipboard

empty recommendations list

Open srcolinas opened this issue 7 years ago • 6 comments

I am getting an empty list of recommendations. Why could it be?

srcolinas avatar Jul 05 '18 23:07 srcolinas

How would we know without looking at your code ?

DollarAkshay avatar Jul 06 '18 09:07 DollarAkshay

Sorry for that, I thought there could be a conceptual reason.

Nonetheless, here is some code:

from implicit.als import AlternatingLeastSquares

ials = AlternatingLeastSquares()
ials.fit(movielens.train.transpose())

ials.recommend(2, movielens.train, N=10)

In this code, I store a csr_matrix of shape (n_users, n_items) in movielens.train, which is basically the ml-100k dataset but with 10 ratings removed from each user only if the user has rated more than 20. Moreover, I set all ratings bellow 3.5 to 0, to treat it as an implicit dataset.

My thought is that maybe I am turning the movielens dataset to implicit wrongly.

srcolinas avatar Jul 06 '18 13:07 srcolinas

Does the user have any liked item in the train set?

benfred avatar Jul 06 '18 17:07 benfred

it seems to be the case because:

np.unique(movielens.train[2, :])
array([0., 4., 5.], dtype=float32)

srcolinas avatar Jul 06 '18 18:07 srcolinas

@srcolinas - I believe in this case the user will get a zero vector for their factors, because of this code: https://github.com/benfred/implicit/blob/master/implicit/_als.pyx#L165 I'm surprised that it doesn't return anything though (I would have thought it would return random results instead here).

I'm not sure what the correct behaviour here should be - maybe throw an error?

benfred avatar Jul 16 '18 20:07 benfred

@benfred throwing an error seems ok

srcolinas avatar Jul 16 '18 22:07 srcolinas