-
Notifications
You must be signed in to change notification settings - Fork 608
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
als explain method bug #701
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm encountering an issue when running the explain method. I'm unsure of what is going wrong, but it seems like the dimensions of some matrix are being unintentionally flipped at some point.
The only userid that appears to dodge the issue is 0, but there is no such user in the training data I'm working with.
Below is code and output. Any feedback would be greatly appreciated!
{'post_id': array([127664, 105085, 160655, 205782, 187429, 185678, 188119, 265365,
177336, 220538], dtype=int32), 'score': array([0.38005394, 0.3619479 , 0.35976228, 0.3480073 , 0.34047693,
0.34022546, 0.33973548, 0.33651435, 0.33490524, 0.3335871 ],
dtype=float32), "already_fav'd": array([False, False, False, True, True, True, True, True, True,
False])}
{'post_id': array([127664, 105085, 160655, 205782, 187429, 185678, 188119, 265365,
177336, 220538], dtype=int32), 'score': array([0.38005394, 0.36194786, 0.35976222, 0.3480073 , 0.34047693,
0.34022546, 0.33973545, 0.33651435, 0.33490527, 0.3335871 ],
dtype=float32), "already_fav'd": array([False, False, False, True, True, True, True, True, True,
False])}
**IndexError Traceback (most recent call last)
/home/eostendarp/workspace/e621/notebook.ipynb Cell 10 line 1
----> 1 cpu_model.explain(23, user_post[user_id], 127664)
File ~/workspace/e621/venv/lib/python3.10/site-packages/implicit/cpu/als.py:386, in AlternatingLeastSquares.explain(self, userid, user_items, itemid, user_weights, N)
383 # user_weights = Cholesky decomposition of Wu^-1
384 # from section 5 of the paper CF for Implicit Feedback Datasets
385 if user_weights is None:
--> 386 A, _ = user_linear_equation(
387 self.item_factors, self.YtY, user_items, userid, self.regularization, self.factors
388 )
389 user_weights = scipy.linalg.cho_factor(A)
390 seed_item = self.item_factors[itemid]
File ~/workspace/e621/venv/lib/python3.10/site-packages/implicit/cpu/als.py:503, in user_linear_equation(Y, YtY, Cui, u, regularization, n_factors)
500 # accumulate YtCuPu in b
501 b = np.zeros(n_factors)
--> 503 for i, confidence in nonzeros(Cui, u):
504 factor = Y[i]
506 if confidence > 0:
File ~/workspace/e621/venv/lib/python3.10/site-packages/implicit/utils.py:11, in nonzeros(m, row)
9 def nonzeros(m, row):
10 """returns the non zeroes of a row in csr_matrix"""
---> 11 for index in range(m.indptr[row], m.indptr[row + 1]):
12 yield m.indices[index], m.data[index]
IndexError: index 23 is out of bounds for axis 0 with size 2**
The text was updated successfully, but these errors were encountered: