Alternating Least Squares (ALS)
Factorising a huge, mostly-empty interaction matrix sounds forbidding until you notice one thing: if you freeze the item side, solving for every user is just ridge regression. Alternating Least Squares turns that observation into an algorithm.
How the alternation works
ALS holds the item factors fixed and solves each user's factor vector in closed form, minimising squared error on that user's observed entries with an L2 penalty. Then it freezes the user factors it just computed and does the same for every item. Each half-sweep is an exact solution rather than a step towards one, so there is no learning rate to tune and the objective cannot increase. A typical run converges in ten to twenty sweeps.
The implicit-feedback variant
For clicks and plays there are no negatives, so the implicit formulation treats every unobserved cell as a weak zero and attaches a confidence weight that grows with observed interaction strength. Written naively, each sweep would scale with the full user-item grid; the standard trick precomputes the item-factor Gram matrix once per sweep, so the per-user cost depends only on that user's observed items. That is what makes the method practical on a catalogue of millions.
Why it matters
ALS is the workhorse for implicit collaborative filtering at scale, and the reason is structural:
- Every user solve is independent of every other, so a sweep distributes cleanly — this is the ALS in Spark MLlib and in the Python implicit library.
- It is deterministic and forgiving to set up, where SGD-based factorisation such as Funk SVD needs a learning-rate schedule.
- It optimises weighted squared error, so when the goal is the order of a top-N list rather than reconstruction, a pairwise objective such as BPR is the better fit.
Alternating Least Squares fits a matrix factorisation by freezing the item factors and solving every user factor in closed form as a regularised least-squares problem, then swapping the roles and repeating. Each half-sweep is exact, so there is no learning rate, and the per-user solves are independent, which makes it distribute across machines. With confidence weights on unobserved cells it is the standard trainer for implicit feedback at catalogue scale.
Picture a desk with two rows of dials. The left row describes what each person likes. The right row describes what each item is. Twisting all of them at once is hopeless, but if you hold one row still, the best setting for the other row can be worked out exactly.
That is Alternating Least Squares. It fixes the item dials and solves the people dials, then fixes the people dials and solves the item dials, back and forth until the numbers stop moving. Each pass is a clean calculation rather than a guess, and because every person can be handled separately, the work splits across many machines — which is how it copes with millions of users and items.