Non-Negative Matrix Factorization (NNMF) aims to factorise the non-negative $n \times m$ matrix $V$ into two non-negative factor matrices $W$ ($n \times k$) and $H$ ($k \times m$) such that :
\begin{align}
min_{W,H} || V - WH||_F
\end{align}
ie. the Frobenius norm of the residual matrix $D = V - WH$ is minimised, this suggests that $V \approx WH$. Sometimes additional constraints inducing sparsity and/or smoothness properties on the matrices $W$ and $H$ are added but these are not part of the fundamental task of NNMF. Therefore (using the example in the documentation of the function rnmf
) after retrieving the NNMF results:
data("tumor")
tumor.corrupted <- tumor
set.seed(1)
tumor.corrupted[sample(1:4900, round(0.05 * 4900), replace = FALSE)] <- 1
res.rnmf1 <- rnmf(X = tumor.corrupted, gamma = FALSE, my.seed = 1)
We can calculate the associated Frobenius norm using:
norm( tumor.corrupted - res.rnmf1$W %*% res.rnmf1$H, type = 'f')
Notice that it is good practice to have a few runs using different random seeds to generate the initial solution when using an NNMF decomposition. The minimisation task solved has local minima which may lead to different matrices $W$ and $H$.
I strong recommend going through the Berry et al. paper "Algorithms and Applications for Approximate Nonnegative Matrix Factorization"; it is very nicely written and gives an all-round overview of NNMF's internal mechanics as well as applications.