Initialization
ludvigla opened this issue · 2 comments
Hi there,
Thanks for an excellent R package!
I was wondering if you have any plan to implement an option to leverage user specified initial matrices for the nmf similar to the nnmf
function in this package?
Cheers,
Ludvig
Hi Ludvig,
This feature is available in the development version of RcppML available on GitHub. Use the seed
argument in the nmf
function to specify the initial matrix. Note that you can only specify the initial w
matrix, because the h
matrix is computed from w
during the first iteration and so there is no sense in seeding h
(not in the NNLM package either).
devtools::install_github("zdebruine/RcppSparse")
devtools::install_github("zdebruine/RcppML")
library(RcppML)
library(Matrix)
A <- rsparsematrix(100, 100, 0.1)
w_init <- matrix(runif(100*10), 100, 10)
nmf_model <- RcppML::nmf(A, k = 10, seed = w_init)
You can also specify a list of initial matrices.
Hopefully I will be able to migrate this feature to the CRAN version soon.
Best,
Zach
Fantastic Zach, thanks!
I will try it right away :-)