Non-Negative Matrix Factorization Calculator
Enter a non-negative matrix.

Why NMF?

Non-negative matrix factorization (NMF) seeks matrices W and H with no negative entries such that VWH. 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

HHWTVWTWH

and

WWVHTWHHT

where denotes element-wise multiplication and division occurs element-wise as well. These rules guarantee that if W and H 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 W may capture a basis element while each row of H provides the coefficients needed to reconstruct a particular observation.

Related Calculators

Eigenvalue and Eigenvector Calculator - Understand Matrix Behavior

Calculate eigenvalues and eigenvectors of a 2x2 matrix. Useful for systems analysis, vibrations, and more.

eigenvalue calculator eigenvector calculator linear algebra

Pythagorean Triple Generator - Explore Integer Right Triangles

Generate primitive and non-primitive Pythagorean triples using Euclid's formula.

Pythagorean triple generator integer right triangles

Rational Root Theorem Calculator - Find Fractional Solutions

Apply the rational root theorem to polynomial coefficients and discover all possible rational zeros.

rational root theorem calculator polynomial roots