Skip to content

Instantly share code, notes, and snippets.

@yuitest
Last active November 19, 2015 19:32
Show Gist options
  • Save yuitest/b26db553c555c8925a40 to your computer and use it in GitHub Desktop.
Save yuitest/b26db553c555c8925a40 to your computer and use it in GitHub Desktop.
# https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/decomposition/nmf.py
from sklearn.decomposition import NMF
import numpy
A = numpy.random.uniform(size=[40, 30])
nmf_model = NMF(n_components=3, init='random', random_state=0)
nmf_model.fit(A)
W = nmf_model.fit_transform(A)
H = nmf_model.components_
print(A.shape)
print(W.shape)
print(H.shape)
print(numpy.dot(W, H).shape)
print(A - numpy.dot(W, H))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment