sklearn NMF, the inference weight values are changed whenever I try it again

149 views Asked by At

Whenever I'm doing inference (nmf_model.transform(matrix)) The weight value of each topics for documents are changed.

from sklearn.decomposition import NMF

nmf_model = NMF(
  n_components = 7,
  init = 'nndsvda',
  solver = 'mu',
  beta_loss = 'Frobenius',
  max_iter = 500,
  tol = 0.000001, 
  alpha = 0.1,
  l1_ratio = 0,
  shuffle = True
)

I'm doing Topic modeling using NMF.

I saved this model and doing an inference. But I tried it twice, the result was changed.

For example,

version 1 : 
topic_001 : weight 0.013663
topic_002 : weight 0.072554
topic_003 : weight 0.000056 

....

but version 2 doesn't have same weight value with version 1, even I didn't change anything when I'm doing an inference.

Below is my Inference code

data_mat = csc_matrix.transpose(gensim.matutils.corpus2csc(ref_corpus + corpus))[len(ref_corpus):]

nmf_model.transform(data_mat)

Does anyone knows why its happend? I want to fix it so that I can get same values whenever I try it again.

0

There are 0 answers