Non-negative matrix factorization (NMF) seeks matrices and with no negative entries such that . By enforcing positivity, NMF often yields more interpretable factors than unconstrained decompositions. For instance, document-term matrices reveal topics consisting of word frequencies, while pixel intensities decompose into component images. Many data sets are inherently non-negative, and NMF honors that structure.
The algorithm implemented here uses multiplicative update rules introduced by Lee and Seung. Starting from random non-negative matrices, we repeatedly apply
and
where denotes element-wise multiplication and division occurs element-wise as well. These rules guarantee that if and start non-negative, they remain so while gradually reducing reconstruction error. In practice, the updates are repeated for a modest number of iterations until changes stabilize.
This calculator demonstrates the essence of NMF on small matrices. You can enter a matrix of size up to 3x3 and choose a rank (often 2) that represents the number of latent features. After running the algorithm, the resulting matrices are displayed so you can verify that multiplying them yields an approximation of the original. While basic, this example conveys the flavor of larger applications in image processing, audio separation, and recommendation systems.
By experimenting with different ranks and iterations, you can observe how the quality of the approximation improves. The non-negativity constraint often leads to "parts-based" representations: each column of may capture a basis element while each row of provides the coefficients needed to reconstruct a particular observation.
Calculate eigenvalues and eigenvectors of a 2x2 matrix. Useful for systems analysis, vibrations, and more.
Generate primitive and non-primitive Pythagorean triples using Euclid's formula.
Apply the rational root theorem to polynomial coefficients and discover all possible rational zeros.