Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Parts that only add up
Many measurements are naturally positive sums. A spectrum is the sum of each material’s spectrum; a power reading is the sum of what each appliance draws; a document is a mix of topics. NMF factors a table of such data into a few non-negative parts and non-negative amounts of each part per sample. Nothing can cancel out, so the parts come out looking like real, physical pieces.
NMF unmixes hyperspectral pixels into material spectra (remote sensing, planetary science), separates an aggregate power signal into appliances or subsystems, extracts topics from maintenance reports, and decomposes audio into sources. Its components are directly interpretable because they live in the same non-negative units as the data.
- 1. NMF represents each sample as…
- 2. PCA components on non-negative data typically…
- 3. NMF needs the data to be…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Updates and losses by hand
Model. V (m × n) ≈ W H, with W (m × k) ≥ 0 and H (k × n) ≥ 0.
Frobenius loss. ‖V − WH‖². For V = [1, 2], W = [1] and H = [1, 1], the residual is [0, 1] and the loss is 1.
Multiplicative update for H (Frobenius): H ← H ⊙ (WᵀV) ⊘ (WᵀWH). For V = [4, 2], W = [2] and H = [1, 1]: WᵀV = [8, 4] and WᵀWH = [4, 4], so H becomes [2, 1]. The fit then reproduces V exactly. Non-negative entries stay non-negative because the update only multiplies by positive ratios.
KL loss. Σ [V log(V/WH) − V + WH]. For V = 2 and WH = 1: 2 ln 2 − 1 = 0.386. It suits count data (Poisson noise).
Scaling ambiguity. (WD)(D⁻¹H) = WH for any positive diagonal D, so normalise W’s columns (for example to unit sum) and move the scale into H.
Compression. A 60 × 200 matrix (12 000 numbers) with k = 3 needs k(m + n) = 780.
The steps in plain English:
- Make sure V ≥ 0, and choose k and the loss (Frobenius for Gaussian-like noise, KL for counts).
- Initialise W, H ≥ 0 (random, or NNDSVD/NNDSVDa from the SVD).
- Alternate the multiplicative (or ANLS) updates for H and W until the loss stops improving.
- Normalise the columns of W, then interpret W’s columns as parts and H’s rows as their activations.
- 1. One H update for V = [3], W = [1], H = [1]?
- 2. Numbers stored by NMF with m = 100, n = 1000, k = 5?
- 3. KL loss when WH equals V exactly?
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.Why the updates work, initialisation and uniqueness
Monotone multiplicative updates (Lee and Seung, 2001). Each update minimises a quadratic auxiliary (majorising) function of the loss, so the loss never increases, with no step size to tune. They are slow to converge near the solution, and an entry that hits exactly zero stays there. Faster alternatives: alternating non-negative least squares, HALS / coordinate descent, and projected gradient.
Exercise 1, three peaked spectra mixed with random weights:
- NMF reached relative error 0.004 and recovered every spectrum with correlation ≥ 0.9998;
- even after choosing each column’s sign to be mostly positive, 31% of the top-3 SVD factor entries were negative.
Initialisation.
- NNDSVD builds non-negative factors from the leading singular vectors’ positive or negative parts. It contains many zeros, and multiplicative updates cannot move zeros.
- NNDSVDa fills those zeros with the data mean.
In exercise 2, NNDSVDa reached error 0.087 after 10 updates against 0.26 for random initialisation. Plain NNDSVD was the slowest by 50 updates.
Uniqueness. If W H = V, so does (WQ)(Q⁻¹H) whenever both stay non-negative. When parts overlap heavily and activations are dense, many such Q exist, and NMF can fit perfectly yet return the wrong parts. Uniqueness holds under sparsity or separability (each part has an “anchor” feature no other part uses; Donoho and Stodden, 2003). Exercise 2: peaked, sparse factors were recovered at correlation 1.000, while dense, overlapping factors reached only 0.82, despite a fit error of 1.2%.
Choosing k. Plot reconstruction error against k (look for an elbow), check stability of the factors across restarts (consensus clustering), or use cross-validation by masking entries.
from sklearn.decomposition import NMF
model = NMF(n_components=3, init="nndsvda", beta_loss="frobenius", max_iter=500, random_state=0)
W = model.fit_transform(V) # scikit-learn convention: rows are samples, so W holds the activations
H = model.components_ # and H holds the parts- 1. Lee–Seung multiplicative updates guarantee…
- 2. Plain NNDSVD can slow multiplicative updates because…
- 3. NMF factors are unique when the true parts are…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Complexity. Exact NMF is NP-hard in general (Vavasis, 2009). Under separability, a polynomial-time algorithm finds the anchors exactly (Arora et al., 2012), and successive projection or XRAY methods are practical versions of it.
Geometry. The columns of V lie in the cone generated by the columns of W. NMF looks for a k-generator cone containing the data. If the data fill only part of the cone, many cones fit equally well, which is the source of non-uniqueness. Separability means the data include the cone’s extreme rays themselves.
Statistical view. Frobenius NMF corresponds to Gaussian noise. KL NMF corresponds to Poisson noise, and is equivalent to probabilistic latent semantic analysis (PLSA) for documents. Itakura–Saito NMF is scale-invariant and suits audio power spectra. All belong to the β-divergence family.
Interview questions.
- NMF or PCA? NMF for non-negative data where additive parts are meaningful (spectra, counts, images). PCA when signed variation around a mean is natural and orthogonality is useful.
- How do you get more reliable NMF parts? Use sparsity penalties, several restarts with consensus, a sensible k, NNDSVDa initialisation, and check against domain knowledge, such as known reference spectra.
- 1. KL-loss NMF is equivalent to…
- 2. Exact NMF in general is…
- 3. Separability means each part has…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Initialisation and identifiability
History.
- P. Paatero and U. Tapper (1994) introduced positive matrix factorization for environmental data.
- D. Lee and H. S. Seung (1999, 2001) popularised NMF with multiplicative updates and parts-based faces.
- D. Donoho and V. Stodden (2003) studied uniqueness.
- C. Boutsidis and E. Gallopoulos (2008) proposed NNDSVD.
- S. Vavasis (2009) proved NP-hardness; S. Arora et al. (2012) gave provable algorithms under separability.
Exercise 2. 4 factors, 3 datasets. Relative error after 10, 50 and 300 multiplicative updates on the sparse-factor data:
| initialisation | 10 updates | 50 | 300 |
|---|---|---|---|
| random | 0.2608 | 0.0312 | 0.0077 |
| NNDSVD | 0.2011 | 0.0657 | 0.0136 |
| NNDSVDa | 0.0867 | 0.0226 | 0.0075 |
Factor recovery after 600 updates (mean matched correlation with the true parts, then fit error): sparse, peaked factors 1.000 with fit 0.0051; dense, overlapping factors 0.822 with fit 0.0117.
- NNDSVDa gave a big head start. Plain NNDSVD’s exact zeros slowed multiplicative updates enough to fall behind random initialisation after 50 updates.
- A good fit does not mean the true parts. With dense, overlapping factors, NMF fitted the data to about 1% yet recovered the parts only at correlation 0.82: non-uniqueness made visible.
- Sparse, separable parts were recovered essentially perfectly. That is when NMF’s parts can be trusted as physical.
NMF in AI, robotics and aerospace
- Hyperspectral unmixing: decomposing pixels from Earth-observation or planetary imagers into endmember spectra and abundances.
- Load disaggregation: separating aggregate spacecraft or building power into subsystem contributions.
- Topic models for maintenance and incident reports (KL-NMF).
References
- D. D. Lee, H. S. Seung (1999). “Learning the parts of objects by non-negative matrix factorization.” Nature 401.
- D. D. Lee, H. S. Seung (2001). “Algorithms for non-negative matrix factorization.” NeurIPS 13.
- C. Boutsidis, E. Gallopoulos (2008). “SVD based initialization: a head start for nonnegative matrix factorization.” Pattern Recognition 41(4).
- D. Donoho, V. Stodden (2003). “When does non-negative matrix factorization give a correct decomposition into parts?” NeurIPS 16.
- N. Gillis (2020). Nonnegative Matrix Factorization. SIAM.