- Introduced by
- Lee, D. D. & Seung, H. S.
- Year
- 1999
- Type
- Matrix decomposition with non-negativity constraints
What does it do?
Non-negative Matrix Factorization (NMF) is a family of algorithms, introduced by Lee and Seung in their 1999 Nature paper, that approximates a non-negative data matrix V as the product of two lower-rank non-negative matrices W (basis components) and H (encoding coefficients).
Because the non-negativity constraint rules out subtractive combinations, the learned factors tend to be additive, parts-based building blocks that can be read directly as components of the original data. The method is defined by this constraint together with the divergence chosen to measure the gap between V and WH.
The intuition behind the method
Imagine trying to describe a collection of face images by combining a set of facial parts — eyes, nose, mouth, cheekbones — each present to some non-negative degree. PCA would mix subtracting one feature to cancel another, producing abstract components that are hard to interpret. NMF forbids subtraction entirely: every component must contribute positively to the reconstruction. The result is a dictionary of genuine parts, and each data point is described as a non-negative blend of those parts. The same logic applies to text: NMF on a document-term matrix produces topics (basis vectors) that are genuine collections of co-occurring words, and documents are expressed as non-negative mixtures of those topics.
History
Lee and Seung's 1999 Nature paper introduced NMF for learning the parts of objects, showing that the non-negativity constraint produces parts-based components for face images and semantic features for text. Their 2001 NIPS paper gave the multiplicative update algorithms that are the usual reference for implementation. Later work extended NMF in many directions; book-length treatments such as Cichocki et al. (2009) cover these extensions and their use in exploratory data analysis and blind source separation. A side-by-side comparison of NMF, vector quantisation and PCA on face images is reproduced in The Elements of Statistical Learning (2009, p. 555). The method is now used in text mining, chemometrics, hyperspectral remote sensing and computational biology.
When to use it
Choose NMF when the data are non-negative by nature, such as pixel intensities, word counts, spectral amplitudes or gene expression levels, and when the components need to be read as additive parts. Sparse non-negative matrices, such as document-term matrices in text applications, are a typical fit, because most entries are zero and the representation stays non-negative. NMF has been applied to topic modelling of text corpora, hyperspectral unmixing, audio source separation and the identification of gene expression signatures. Do not apply it directly to data with meaningful negative values; a preprocessing step that keeps the data non-negative must be justified for the domain first. The number of components k must be fixed beforehand, so model selection (reconstruction error, stability across runs, domain knowledge) is part of the workflow. If orthogonal components or a unique decomposition are required, PCA or SVD is usually the more suitable choice.
Limitations and considerations
- The objective is non-convex, so results depend on initialisation and a global minimum is not guaranteed.
- The rank k must be chosen before fitting; no criterion selects it automatically, and comparing candidate values can be costly.
- Signed data cannot be factorised directly; forcing them to be non-negative requires preprocessing that can change what the components mean.
- Multiplicative updates can converge slowly on large matrices; projected gradient and alternating least squares variants are often faster in practice.
- The factorisation is not unique in general and the components are not orthogonal, so different solutions can describe the same data with different parts unless sparsity or other constraints are imposed.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- The non-negativity constraint yields additive, parts-based factors that can be read directly without sign conventions.
- The multiplicative updates are simple to implement and keep W and H non-negative without a projection step; under the matching update rule the cost does not increase.
- A figure in The Elements of Statistical Learning (2009, p. 555) compares NMF with vector quantisation and PCA on face images; NMF learns basis images resembling parts of faces, whereas VQ and PCA do not.
- The formulation has been extended in several directions, including to tensor data, as covered in book-length treatments such as Cichocki et al. (2009).
- It applies to any data that are non-negative by nature, including images, text, audio, spectra and expression data.
Applications
- Topic modelling of document-term matrices to extract coherent semantic themes from text corpora.
- Face and object recognition: learning parts-based dictionaries of visual features from image collections.
- Hyperspectral image unmixing to identify pure spectral endmembers and their abundances.
- Audio source separation and music transcription from non-negative time-frequency representations.
- Gene expression analysis: identifying metagenes or expression signatures from microarray and RNA-seq data.
- Recommender systems: collaborative filtering via non-negative user and item factor matrices.
How it works
How it works
The starting point is an m-by-n matrix V, where rows are features (e.g., pixels or vocabulary terms) and columns are observations (e.g., images or documents). NMF seeks two non-negative matrices W (m-by-k) and H (k-by-n) such that their product WH approximates V. The rank k is chosen to be much smaller than both m and n, forcing a compressed, parts-based summary of the data. Both W and H must have all entries greater than or equal to zero; this is the defining constraint that separates NMF from sign-unconstrained decompositions.
Formula
V \approx WH, \quad W \in \mathbb{R}_{\geq 0}^{m \times k},\; H \in \mathbb{R}_{\geq 0}^{k \times n}The quality of the approximation is measured by a divergence between V and WH. The cost stated in the mechanics step is the generalised Kullback-Leibler divergence, which suits count data such as word frequencies because it models their Poisson-like variability. The squared Frobenius (Euclidean) distance is a standard alternative, and the choice should match the data type. Minimising either cost over W and H under non-negativity is a non-convex problem, so a global minimum is not guaranteed and the solution depends on the starting point.
Formula
D(V \| WH) = \sum_{ij} \left[ V_{ij} \log \frac{V_{ij}}{(WH)_{ij}} - V_{ij} + (WH)_{ij} \right]The rule shown multiplies each entry of H by the ratio of W^T V to W^T W H. Because both terms are non-negative, H stays non-negative without a projection step. This ratio is the multiplicative update for the squared Frobenius cost. The generalised KL cost named above is minimised by a different ratio, so each cost and its update rule must be taken as a matched pair.
Formula
H_{a\mu} \leftarrow H_{a\mu} \frac{(W^\top V)_{a\mu}}{(W^\top W H)_{a\mu}}An analogous multiplicative rule updates W, with the roles of rows and columns exchanged, and the same matching condition applies. Updates alternate between H and W until the stopping rule described below is met. For a matched cost and update pair, the objective does not increase from one update to the next. This monotonicity does not guarantee a global minimum.
Formula
W_{ia} \leftarrow W_{ia} \frac{(V H^\top)_{ia}}{(W H H^\top)_{ia}}Convergence is monitored by tracking the objective across iterations. Iteration stops when the relative decrease in the objective falls below a small tolerance or when an iteration limit is reached. Entries of the initial W and H should be strictly positive, since a zero entry remains zero under the multiplicative rules. A small positive constant is commonly added to denominators to avoid division by zero. Because the problem is non-convex, different non-negative starting points can lead to different local solutions, so running NMF from several random starts and keeping the solution with the lowest final cost is common practice. NNDSVD (non-negative double singular value decomposition) is a deterministic alternative that builds the starting matrices from a singular value decomposition; it is often used to reduce dependence on random seeds.
Common pitfalls
- Fitting NMF once from a single random start and reporting the components without checking their sensitivity to initialisation.
- Choosing k by reconstruction error alone; the error generally decreases as k increases, so the stability of the components across runs should also be examined.
- Applying NMF to data that are not non-negative, or normalising the data in a way that introduces negative values before factorisation.
- Ignoring scale ambiguity: W and H can be rescaled inversely without changing WH, so component magnitudes are not comparable across runs until they are normalised.
- Interpreting the components as meaningful parts without checking that the reconstruction error is acceptably low for the task.
Frequently asked questions
How is NMF different from PCA or SVD?
PCA and SVD impose orthogonality but allow both positive and negative values in the components, which can produce holistic, hard-to-interpret representations (e.g., a PCA face component mixes positive and negative pixel weights). NMF forbids negative values entirely, so every component is a genuine part that adds to, never subtracts from, the reconstruction. The trade-off is that NMF components are not orthogonal and the solution is not unique without extra constraints.
How do I choose the number of components k?
There is no universally agreed criterion. Common approaches include plotting reconstruction error against k and looking for a point where further improvement levels off, checking whether the components remain similar across repeated random initialisations, and cross-validation on held-out entries of V. Domain knowledge, such as the expected number of topics in a corpus or spectral endmembers in an image, should inform the choice as well.
Why do I get different results each time I run NMF?
NMF optimises a non-convex objective, so different random initialisations can converge to different local minima. The usual remedy is to run NMF several times from different random starts and keep the run with the lowest final reconstruction error. The NNDSVD initialisation gives a deterministic starting point that reduces dependence on the random seed.
Can NMF be used for topic modelling instead of LDA?
Yes. NMF applied to a TF-IDF or raw count document-term matrix yields word-based topics (basis vectors) and document loadings (encoding matrix) that are often qualitatively similar to those from Latent Dirichlet Allocation. NMF is often simpler to implement and fit, while LDA is a generative probabilistic model with Dirichlet priors. The choice depends mainly on whether a probabilistic model with uncertainty estimates is needed.
Related methods
Sources
Lee, D. D., & Seung, H. S. (1999). Learning the parts of objects by non-negative matrix factorization. Nature, 401(6755), 788–791.
Open DOI referenceLee, D. D., & Seung, H. S. (2001). Algorithms for non-negative matrix factorization. Advances in Neural Information Processing Systems, 13, 556–562.
Open publication referenceCichocki, A., Zdunek, R., Phan, A. H., & Amari, S. (2009). Nonnegative Matrix and Tensor Factorizations: Applications to Exploratory Multi-way Data Analysis and Blind Source Separation. Wiley.
ISBN: 978-0-470-74666-0The Elements of Statistical Learning (2009), p. 555