I am trying to understand NNMF (Non-Negative Matrix Factorization). This is not a built-in function in Mathematica, but there is a package that implements it, which is refered to in this post. The package is loaded by:
Import["https://raw.githubusercontent.com/antononcube/\MathematicaForPrediction/master/NonNegativeMatrixFactorization.m"] The problem that NNMFG tries to solve is this: given a matrix X, factor it as W.H where W and H both have all positive entries. But when I try to apply this using the package, I cannot figure out what is happening. First, construct a matrix x -- I build it random, but of low rank (rank 5):
xKer = RandomInteger[{0, 10}, {5, 5}]; xL = RandomInteger[{0, 10}, {50, 5}]; xR = RandomInteger[{0, 10}, {5, 100}]; x = xL.xKer.xR; Dimensions[x] MatrixRank[x] So you can see x is 50 by 100, but is of rank only 5. Applying the NNMF command from the package:
{w, h} = GDCLS[x, 5, "MaxSteps" -> 1000]; Dimensions[W] Dimensions[H] So we can see that w.h has the same dimensions as x. But
Norm[w.h - x] is very large, so w.h is not a good approximation to x. Thus my questions: why doesn't NNMF seem to work? Am I expecting the wrong thing?