Search code examples
matrixmachine-learningscikit-learnfactorizationdimensionality-reduction

Non Negative Matrix Factorization: How to predict values for a new entry?


My current understanding:
I have tried reading a few papers and links regarding NMF. It all talks about how we can split a MxN matrix into MxR and RxN matrices(R

Question:
I have a list of users(U) and some assignments(A) for each user. Now I split this matrix(UxA) using NMF. I get 2 Matrices UxR and RxA. How do I use these to predict what assignments(A') a new user(U') must have?

Any help would be appreciated as I couldn't understand this after trying to search for the answer.

Side question and opinion based:
Also if anyone can tell me with their experience, how do they chose R, specially when the number of assignments are in the order of 50,000 or perhaps a hundred thousand. I have been trying these with the scikit-learn library

Edit: This can simply be done using model.inverse_transform(model.transform(User'))


Solution

  • You can try think this problem as recommender. you want to approximate decompose matrix X into two nonnegative matrix U and V.

    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(X)
    H = model.components_
    

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

    To predict what assignments(A') a new user(U'), you just use WH' to complete the maitrx