Solve user factors in implicit-feedback ALS with confidence weights
Why it matters Weighted ALS for implicit feedback is a classic production recommender for music, video and shopping data.
For implicit data (play counts, clicks), weighted ALS treats every user-item cell as a preference p = 1 if the count is positive else 0, with confidence c = 1 + alpha * count. Holding item factors fixed, each user's factors have a closed-form solution.
Write implicit_als_users(R, Y, alpha, reg). R is (n_users, n_items) non-negative counts, Y is (n_items, k) item factors. For each user u with C_u = diag(1 + alpha * R[u]) and p_u = (R[u] > 0):
x_u = solve(Y^T C_u Y + reg * I, Y^T C_u p_u).
Return X with shape (n_users, k).
def implicit_als_users(R, Y, alpha, reg)Example
implicit_als_users([[2, 0]], [[1, 0], [0, 1]], 1.0, 1.0) gives array([[0.75, 0.]]).
Understand the idea
Explicit ratings say how much someone liked a thing. Implicit data only says what they did, so a zero might mean dislike or just never seen. Implicit ALS handles this with two numbers per cell: a preference (1 if any interaction, else 0) and a confidence that grows with the count. Every zero is a weak "probably not", every heavy interaction a strong "yes".
Example: one user, two items with identity factors, count 2 on item 0 and alpha 1. Confidences are [3, 1]; preferences [1, 0]. The system is diag(3, 1) + I = diag(4, 2) on the left and [3, 0] on the right, so the user factor is [0.75, 0].
Rule: x_u = (Y^T C_u Y + reg I)^(-1) Y^T C_u p_u, with C_u = diag(1 + alpha r_u), p_u = 1[r_u > 0].
Alternating this with the symmetric item solve gives the full algorithm used in many music and video recommenders.
Shapes and data flow
R: (U, I), Y: (I, k) -> per user A: (k, k), b: (k,) -> X: (U, k)