LA 101
M11 · L02
Module 11: Machine Learning Applications

Matrix Factorization

Large data matrices hide structure no single entry reveals. Matrix factorization — NMF, SVD-based collaborative filtering, LSA — decomposes a matrix into interpretable parts, uncovering latent factors that explain the observed data.

01 / 12
LA 101
M11 · L02
Non-Negative Matrix Factorization

Parts-Based Decomposition

Given V ≥ 0, find W ≥ 0, H ≥ 0 with V ≈ WH. The non-negativity forces additive, parts-based factors — each column of W is a "part", each row of H is a mixture weight. No cancellation allowed.

NMF Objective
\min_{W\geq 0,H\geq 0}\|V-WH\|_F^2
02 / 12
LA 101
M11 · L02
NMF: Learning

Multiplicative Updates

NMF alternates between updating H and W using ratio-based gradient steps that guarantee non-negativity throughout. Converges to a local minimum — the problem is non-convex in (W,H) jointly.

W
Parts dictionary
H
Mix weights
k
Num. factors
03 / 12
LA 101
M11 · L02
NMF vs. PCA

Parts vs. Holistic

PCA allows negative coefficients — components can cancel, producing holistic representations. NMF only adds, never subtracts. For images this means facial features (eyes, nose, mouth), not eigen-face blends. Far more interpretable in human terms.

Examples
Images: pixel patches · Text: topic distributions · Audio: spectral templates
04 / 12
LA 101
M11 · L02
Recommender Systems

Collaborative Filtering

Ratings matrix R is low-rank: a few latent factors (genres, styles) explain most variance. Learn user vectors pᵢ and item vectors qⱼ in a shared latent space. Predicted rating: r̂ᵢⱼ = pᵢᵀqⱼ.

MF Objective
\min\sum_{(i,j)\in\Omega}(r_{ij}-p_i^T q_j)^2+\lambda(\|p_i\|^2+\|q_j\|^2)
05 / 12
LA 101
M11 · L02
Latent Space Geometry

Users, Items, and Similarity

After training, pᵢ and qⱼ live in the same k-dimensional space. Similar items cluster — even with no shared explicit features. Similar users cluster too. The dot product pᵢᵀqⱼ measures alignment: large value → predicted high rating.

pᵢᵀqⱼ
Predicted rating
‖pᵢ−pⱼ‖
User distance
06 / 12
LA 101
M11 · L02
Eckart–Young Theorem

Optimal Low-Rank Approximation

The best rank-k approximation to A (in Frobenius and spectral norm) is the truncated SVD: keep only the k largest singular values. Error = σₖ₊₁² + … + σᵣ². No other rank-k matrix gets closer.

Truncated SVD
A_k=U_k\Sigma_k V_k^T=\sum_{i=1}^{k}\sigma_i\mathbf{u}_i\mathbf{v}_i^T
07 / 12
LA 101
M11 · L02
Latent Semantic Analysis

SVD on Text

Build a TF-IDF term-document matrix A. Truncate its SVD to rank k. The resulting concept vectors capture synonymy (same-meaning words cluster) and survive polysemy. Document similarity = cosine of concept vectors — even documents sharing no words can be similar.

  • Rows of UₖΣₖ: concept vectors for terms
  • Columns of ΣₖVₖᵀ: concept vectors for documents
  • k components = k latent "topics"
08 / 12
LA 101
M11 · L02
Word Embeddings

GloVe and PMI Factorization

GloVe explicitly factorizes the log co-occurrence matrix: wᵢᵀw̃ⱼ ≈ log Xᵢⱼ. Word2Vec implicitly does the same for the shifted PMI matrix. Result: semantic analogies as geometry — king − man + woman ≈ queen in embedding space.

GloVe
Explicit factorization
W2V
Implicit PMI
09 / 12
LA 101
Matrix factorization

Check what stuck

Four questions on NMF, collaborative filtering, LSA and embeddings as factorizations.

Question 1 of 0
Score 0/0

10 / 12
LA 101
Key Takeaways
Summary

Key Takeaways

  • NMF: V ≈ WH with W,H ≥ 0 → parts-based, interpretable factors
  • Collaborative filtering: low-rank R ≈ PQᵀ; predict rᵢⱼ = pᵢᵀqⱼ
  • Eckart–Young: truncated SVD is the optimal rank-k approximation
  • LSA: SVD on TF-IDF matrix captures synonymy and latent topics
  • Word embeddings (GloVe/W2V): implicitly factorize log co-occurrence — analogy = geometry
11 / 12
LA 101
Up Next
Coming Up

M11-L3: Neural Network Fundamentals

We've seen how matrix factorization discovers hidden structure. Next: how neural networks chain matrix multiplications — forward propagation, backpropagation as Jacobian chain rule, and the attention mechanism as a QKV matrix operation.

12 / 12