In alternating least squares (ALS) for matrix factorisation, a user has rated two items, with item vectors and fixed and ratings and . (a) Derive the update that minimises for the user vector . (b) Compute for , and for . (c) Why is ALS attractive for large recommenders?
Unsupervised learning, Matrix factorisation
Level L3 Intermediate. Length Long. Nature Mat Mathematical.
What's being asked
Whether you can derive the ridge-regression update behind ALS and use it numerically.
Key idea
With item vectors fixed, the user vector solves a ridge regression: , where the rows of are the rated items' vectors and holds the ratings.
Steps
- Stack the rated items' vectors as the rows of and the ratings in a vector . The objective is .
- Set the gradient to zero: , so and .
- Here , so and .
- For : with determinant , and inverse . So . The predictions are and , shrunk below the ratings and .
- For : solves and , so and both ratings are fitted exactly. With few ratings this overfits, which is why the penalty is needed.
- Then the same step is applied to every item vector with the user vectors fixed, and the two sweeps alternate. Each sweep decouples across users (or items), so it parallelises well and handles implicit-feedback data, and each subproblem is convex even though the joint problem is not.
Common mistakes
- Forgetting that only the items this user rated appear in . Using all items treats missing entries as zero ratings.
- Using the same without scaling by the number of ratings, which penalises users with many ratings less than users with few (weighted- regularisation fixes this).
- Claiming ALS finds the global optimum. It decreases the objective at every step but may stop at a local minimum.
How long your answer should be
Half a page to a page; 6 minutes.
Last checked on 4 December 2026.
Read this
Previous in Unsupervised learning: An isolation forest uses sub-samples of size and scores a point with , where . (a) Compute . (b) Find for average path lengths , and and say what each means. (c) Why is in the formula?
Next in Unsupervised learning: Probabilistic PCA models with and . The maximum-likelihood solution is and . (a) For and sample covariance eigenvalues , find and the scale of each column of for . (b) Why does the covariance of the model match the data in the top directions? (c) How does PPCA relate to ordinary PCA as ?