Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Hidden dimensions of taste
Suppose every film could be scored on a few hidden scales, such as how much action it has or how cerebral it is, and every viewer had a matching set of preferences. Then a viewer’s rating of a film would be roughly how well their preferences line up with the film’s scores. Matrix factorisation discovers such scales automatically from the ratings alone, giving every user and every item a short list of numbers, and predicts any missing rating by combining the two lists.
Low-rank factorisation is one of the most reused ideas in data science: recommenders, completing sparse sensor or test matrices, embedding users, parts and documents, and compressing large tables. The same “learn embeddings so that their dot products match observations” principle underlies word embeddings and two-tower retrieval models.
- 1. Matrix factorisation gives each user and item…
- 2. A predicted rating combines…
- 3. The hidden factors are learned from…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.The model and one SGD step by hand
Model. r̂ᵤᵢ = μ + bᵤ + bᵢ + pᵤ·qᵢ. With μ = 3.5, bᵤ = 0.2, bᵢ = −0.3, pᵤ = (1, 0.5) and qᵢ = (0.4, 0.2): 3.4 + 0.5 = 3.9.
Objective. Minimise over observed (u, i) only:
Σ (rᵤᵢ − r̂ᵤᵢ)² + λ(Σbᵤ² + Σbᵢ² + Σ‖pᵤ‖² + Σ‖qᵢ‖²).
SGD update for one rating, with error e = rᵤᵢ − r̂ᵤᵢ and learning rate η:
- bᵤ ← bᵤ + η(e − λbᵤ), and bᵢ likewise;
- pᵤ ← pᵤ + η(e qᵢ − λpᵤ);
- qᵢ ← qᵢ + η(e pᵤ − λqᵢ).
Starting from μ = 3.5, zero biases and pᵤ = qᵢ = (0.1, 0.1), a rating of 5 gives e = 5 − 3.52 = 1.48, so with η = 0.1 and λ = 0 the bias bᵤ becomes 0.148.
Parameter count. (m + n)(k + 1) + 1 = 8801 for 600 users, 200 items and k = 10, against 120 000 matrix entries.
The steps in plain English:
- Centre on μ, and initialise the biases at 0 and the factors with small random values.
- Loop over observed ratings in random order, applying the SGD updates, for a few dozen epochs.
- Choose k and λ, and the number of epochs, by validation RMSE.
- Predict any rating as μ + bᵤ + bᵢ + pᵤ·qᵢ; use the factors as embeddings for similarity and search.
- 1. Funk SVD fits the factors to…
- 2. λ in the objective controls…
- 3. The factor update for pᵤ moves along…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.Why not plain SVD?
Eckart–Young. For a fully observed matrix A, truncating its SVD to k components gives the best rank-k approximation in Frobenius norm. Ratings matrices are 90–99% missing: to use SVD you must fill the gaps first, with zeros or baseline predictions, and then the decomposition fits those invented values as if they were data.
Funk SVD. It fits only the observed entries. The objective is non-convex in (P, Q) but convex in each one with the other fixed, and SGD finds good solutions in practice. Regularisation is essential: with k factors per user and just a few ratings, an unregularised model can fit every training rating.
Biases matter. Most of the predictable variance is user and item bias. Including bᵤ and bᵢ explicitly lets the factors focus on interactions, which is taste.
Exercise 1 (600 users × 200 items, 10.8% observed). Held-out RMSE:
- bias baseline 0.948;
- SVD of the baseline-imputed matrix (rank 5) 0.890;
- Funk SVD (k = 10, λ = 0.05) 0.808, with training RMSE 0.539.
On this same split, the item-based k-NN of the previous topic scored 0.852.
from surprise import SVD
algo = SVD(n_factors=10, reg_all=0.05, lr_all=0.01, n_epochs=40, biased=True) # Funk-style biased MF- 1. Plain SVD on a ratings matrix first needs…
- 2. Funk SVD's objective is…
- 3. Explicit biases let the factors focus on…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Low-rank matrix completion. If the true matrix has rank k, satisfies an incoherence condition, and has about k·n·polylog(n) entries observed uniformly at random, nuclear-norm minimisation recovers it exactly (Candès and Recht, 2009). The λ‖P‖² + λ‖Q‖² penalty is a variational form of the nuclear norm: ‖X‖* = min over X = PQᵀ of ½(‖P‖² + ‖Q‖²).
Extensions.
- SVD++ adds implicit feedback (which items a user rated).
- timeSVD++ adds time-varying biases.
- Non-negative MF gives parts-based factors.
- Probabilistic MF (Salakhutdinov and Mnih, 2008) is the Bayesian reading of the same model: Gaussian priors correspond to L2 penalties.
Identifiability. The factors are determined only up to an invertible transformation: PQᵀ = (PA)(QA⁻ᵀ)ᵀ. With L2 regularisation, rotations remain free, so individual factor dimensions need not be interpretable, even when the clustering of items is.
Interview questions.
- How do you choose the number of factors? By validation error over a grid of (k, λ), and with early stopping. Larger k needs more regularisation, and performance plateaus or degrades past the data’s effective rank.
- Matrix factorisation or neighbourhood methods? MF captures global structure and gives compact embeddings; neighbourhoods capture local relations and explain easily. In the Netflix Prize, blends of both won.
- 1. The L2 penalty on P and Q relates to…
- 2. Probabilistic MF interprets L2 penalties as…
- 3. Individual factor dimensions are…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Factors and regularisation
History.
- S. Funk (2006) described incremental SVD for the Netflix Prize.
- R. Salakhutdinov and A. Mnih (2008) introduced probabilistic MF.
- Y. Koren, R. Bell and C. Volinsky (2009) described biased MF in the Netflix Prize.
- E. Candès and B. Recht (2009) proved matrix-completion guarantees.
- Koren’s SVD++ (2008) added implicit feedback.
Exercise 2. The same data, generated with 5 latent factors. Each cell gives training RMSE, then held-out RMSE.
| k | λ = 0 | λ = 0.02 | λ = 0.1 |
|---|---|---|---|
| 2 | 0.711, 0.899 | 0.720, 0.897 | 0.787, 0.907 |
| 5 | 0.439, 0.697 | 0.449, 0.693 | 0.529, 0.730 |
| 10 | 0.451, 0.843 | 0.481, 0.812 | 0.641, 0.836 |
| 30 | 0.270, 0.869 | 0.330, 0.823 | 0.559, 0.823 |
- The best held-out error came at the true rank, k = 5 (0.693). Too few factors (k = 2) underfit both sets.
- More factors kept lowering training error but raised held-out error. k = 30 with no regularisation fitted training ratings to 0.270 RMSE, below the noise level of about 0.58, and generalised worse (0.869). That is overfitting.
- Regularisation reduced overfitting at large k (0.869 → 0.823 at k = 30) but underfit at the right k (λ = 0.1 at k = 5: 0.730). λ must be tuned together with k.
- Early stopping, small initialisation and the finite number of epochs also act as implicit regularisers: even unregularised k = 10 did not blow up.
Matrix factorisation in AI, robotics and aerospace
- Sparse test-matrix completion: predict untested combinations of configurations and conditions from a partially filled test campaign.
- Fleet health embeddings: factorise asset × sensor-statistic matrices into low-dimensional health states.
- Recommendation and retrieval: user and document embeddings for engineering knowledge systems, trained from usage logs.
References
- Y. Koren, R. Bell, C. Volinsky (2009). “Matrix factorization techniques for recommender systems.” IEEE Computer 42(8).
- S. Funk (2006). “Netflix update: try this at home.” Blog post, sifter.org.
- R. Salakhutdinov, A. Mnih (2008). “Probabilistic matrix factorization.” Advances in NeurIPS 20.
- E. J. Candès, B. Recht (2009). “Exact matrix completion via convex optimization.” Foundations of Computational Mathematics 9(6).
- Y. Koren (2008). “Factorization meets the neighborhood: a multifaceted collaborative filtering model.” Proc. ACM KDD.