I apply non-negative matrix factorization (NMF) to a large matrix. In essence, the NMF method does the following: given m to n matrix A, NMF decomposes into A = WH, where W is m by d, and H is by n. The ProjectedGradientNMF method is implemented in the Python Sklearn package. I would like the algorithm to return both W and H. But it seems that it returns H, not W. Applying the algorithm again to AT (transpose) can give me W. However, I would like to avoid it twice, since the matrix ix very big.
If you could tell me how to get W and H at the same time, that would be great! Below is my code:
from sklearn.decomposition import ProjectedGradientNMF import numpy A = numpy.random.uniform(size = [40, 30]) nmf_model = ProjectedGradientNMF(n_components = 5, init='random', random_state=0) nmf_model.fit(A) H = nmf_model.components_.T
source share