0

While using non-negative matrix factorization for generating recommendations, how do I reconstruct data for a new user?

I am following this equation data.dot(H.T.dot(np.linalg.pinv(H.dot(H.T))).dot(H)) for reconstruction where H represents the latent components and data consists of the new data containing missing entries.

But seem to be going wrong somewhere, since I do not get the expected results (those from other methods such as sklearn NMF, specifically the inverse_transform method).

Vivek Sethia
  • 9
  • 1
  • 4
  • [Two people](https://stackoverflow.com/questions/49340540/reconstructing-new-data-using-sklearn-nmf-components-vs-inverse-transform-does-n) working on the same task at the same university at the same time? Maybe you should speak to each other :-). Anyways: you both misinterpret what ```inverse_transform``` does, as described in the link above. – sascha Mar 17 '18 at 21:56
  • Thanks, will check with the aforementioned. However, I still do not seem to understand what I missed in inverse_transform.. Do you mind elaborating a bit? – Vivek Sethia Mar 18 '18 at 07:59

1 Answers1

3

see https://cambridgespark.com/content/tutorials/implementing-your-own-recommender-systems-in-Python/index.html

For pyothn scikit-learn, you can use: http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.NMF.html

from sklearn.decomposition import NMF
model = NMF(n_components=2, init='random', random_state=0)
W = model.fit_transform(data)
H = model.components_

Where data is the matrix you want to decomose. W and H is the nonnegative factor

you can predict the new recommend or called completed the data matrix by WH'

jason
  • 1,998
  • 3
  • 22
  • 42