Open tangbufanwei opened 10 months ago
model1.recommend(0,user_item_sparse1[0]) THIS IS THE METHOD I FOUND ON GITHUB BUT SEEMS ITS NOT WORKING ON MY SIDE AS WELL.
I think your issue is here:
data_conf = (item_user_sparse1 * alpha_val).astype('double')
model1.fit(data_conf)
model1.recommend(0,user_item_sparse1[0])
The fit
methods take a user_item sparse matrix , https://benfred.github.io/implicit/api/models/cpu/als.html#implicit.cpu.als.AlternatingLeastSquares.fit instead of the item_user sparse matrix that you are passing it.
Does calling the fit
function with the correct argument work for you?
model1.fit(user_item_sparse1)
model1.recommend(0,user_item_sparse1[0])
Thank for your reply but i got several weird arrays, i am not sure if it's correct, but finally it's not red anymore.
and my sparse matrix looks like this
Hi guys i met trouble when i was trying to create a recommender system in python by als(alternating least square). Here is the code. user_item = df_no_duplicates.pivot(index='userId', columns='productId', values='rating').fillna(0) print('Shape of User-Item sparse matrix:', user_item.shape) user_item.head() model1 = implicit.als.AlternatingLeastSquares(factors=20, regularization=0.1, iterations=20) user_item_sparse1 = sparse.csr_matrix(user_item) alpha_val = 40 data_conf = (item_user_sparse1 * alpha_val).astype('double') model1.fit(data_conf) model1.recommend(0,user_item_sparse1[0]) and i got the error index 945 is out of bounds for axis 1 with size 240 in method i found on github, if i use model1.recommend(0,user_item_sparse1) it will turn out to be user_items must contain 1 row for every user in userids i checked the columns of the sparse matrix and the origin one they are exactly the same, so can anyone help me regarding this? THANKS A LOT!