<jupyter_start><jupyter_text>Classical NMF (Multiplicative Update Rule)<jupyter_code>from libnmf.nmf import NMF


nmf = NMF(X, rank=4)
nmf.compute_factors(10)

print nmf.W.shape, nmf.H.shape
print nmf.frob_error<jupyter_output>(10, 4) (4, 10)
[ 2.67875825  2.56017411  2.46989022  2.39325936  2.32661969  2.26763673
  2.21493912  2.16796363  2.12655777  2.09052199]<jupyter_text>Graph Regularized NMF<jupyter_code>from libnmf.gnmf import GNMF

gnmf= GNMF(X, rank=4)
gnmf.compute_factors(20, 0.3, 'heat-kernel', 0.4)
print gnmf.W.shape, gnmf.H.shape
print gnmf.frob_error<jupyter_output>(10, 4) (4, 10)
[ 2.69043073  2.53653322  2.43541254  2.34411797  2.26460573  2.20022371
  2.15114629  2.11475599  2.08765523  2.0669453   2.05053787  2.03702941
  2.02549199  2.01530269  2.00602904  1.99735839  1.98905603  1.98094103
  1.97287266  1.96474302]<jupyter_text>First-order Primal-Dual Algo for NMF<jupyter_code>from libnmf.fpdnmf import FPDNMF

fpdnmf= FPDNMF(X, rank=4)
fpdnmf.compute_factors(max_iter=30, nditer=5)

print fpdnmf.W.shape, fpdnmf.H.shape
print fpdnmf.div_error<jupyter_output>(10, 4) (4, 10)
[ 1.8732198   1.48733369  1.06562005  0.8855369   0.84309262  0.82421472
  0.80169988  0.79223389  0.78623986  0.78196843  0.7783273   0.77511633
  0.77146641  0.76793084  0.76410372  0.75965792  0.7545391   0.74888615
  0.74297444  0.73722608  0.73210623  0.72747017  0.72157562  0.71536247
  0.70930222  0.70460564  0.70079361  0.69760451  0.69502778  0.69289996]<jupyter_text>Alternating Least Squares NMF<jupyter_code>from libnmf.alsnmf import ALSNMF

alsnmf = ALSNMF(X, rank=4)
alsnmf.compute_factors(20)

print alsnmf.W.shape, alsnmf.H.shape
print alsnmf.frob_error<jupyter_output>(10, 4) (4, 10)
[ 2.38981939  2.1122609   1.95020197  1.79489147  1.72181482  1.70114248
  1.69324436  1.68893171  1.68517145  1.68157813  1.67790996  1.67427731
  1.6709191   1.66804831  1.66584231  1.66456596  1.66396045  1.66369678
  1.66356904  1.66350083]<jupyter_text>Probabilistic NMF<jupyter_code>from libnmf.pnmf import PNMF

pnmf = PNMF(X, rank=4)
pnmf.compute_factors(20, 0.3, 0.2)

print pnmf.W.shape, pnmf.H.shape
print pnmf.frob_error<jupyter_output>(10, 4) (4, 10)
[ 2.906903    2.78035603  2.67440571  2.57705409  2.49313229  2.42445874
  2.36927423  2.32501976  2.28939006  2.26037291  2.23625878  2.21564916
  2.19743668  2.18078449  2.16510657  2.15003822  2.13539281  2.12110888
  2.10719567  2.09368737]
{'fraction_non_alphanumeric': 0.10996279454319967, 'fraction_numerical': 0.3906572964034725, 'mean_word_length': 4.105485232067511, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '580488', 'license': 'MIT', 'n_tokens_mistral': 1726, 'n_tokens_neox': 1221, 'n_words': 196, 'path': 'examples/Simple-Usage.ipynb', 'repo_name': 'satwik77/libnmf', 'size': '2419'}