Suppose I want to get a rank-1 approximation to a matrix that happens to be $(1, 2, 0 \ 3, 6, 0)$. There is a unique (up to scaling) perfect factorization $(1 \ 3) * (1, 2, 0)$.
I try the following code:
fitted(nmf(matrix(c(1, 2, 3, 6, 0, 0), nrow = 2), 1, 'lee'))
which returns $(1, 3, 0.002) \ (2, 6, 0.003)$. There's a bit of weird rounding in the third column, but otherwise it works!
Next, I try the brunet algorithm:
fitted(nmf(matrix(c(1, 2, 3, 6, 0, 0), nrow = 2), 1, 'brunet'))
Which throws an error:
non-conformable arrays
Finally, I try the snmf/r algorithm
fitted(nmf(matrix(c(1, 2, 2, 4), nrow = 2), 1, 'snmf/r'))
which throws an error:
'a' is 0-diml
The second and third errors are uninformative as a user. Is it possible to generate a more informative error for this case, whatever the problematic case is?
Suppose I want to get a rank-1 approximation to a matrix that happens to be $(1, 2, 0 \ 3, 6, 0)$. There is a unique (up to scaling) perfect factorization $(1 \ 3) * (1, 2, 0)$.
I try the following code:
fitted(nmf(matrix(c(1, 2, 3, 6, 0, 0), nrow = 2), 1, 'lee'))
which returns $(1, 3, 0.002) \ (2, 6, 0.003)$. There's a bit of weird rounding in the third column, but otherwise it works!Next, I try the brunet algorithm:
fitted(nmf(matrix(c(1, 2, 3, 6, 0, 0), nrow = 2), 1, 'brunet'))
Which throws an error:non-conformable arrays
Finally, I try the snmf/r algorithm
fitted(nmf(matrix(c(1, 2, 2, 4), nrow = 2), 1, 'snmf/r'))
which throws an error:'a' is 0-diml
The second and third errors are uninformative as a user. Is it possible to generate a more informative error for this case, whatever the problematic case is?