mims-harvard / nimfa

Nimfa: Nonnegative matrix factorization in Python
http://ai.stanford.edu/~marinka/nimfa/
Other
541 stars 135 forks source link

How to use the bmf function to obtain a binary matrix? #63

Open wellfrogliu opened 2 years ago

wellfrogliu commented 2 years ago

I read the introdcution for the bmf function in nimfad and it's great! But when i used bmf function, i could not get binary matrix w. My code is : `import numpy as np import nimfa

V = np.random.rand(23, 200)

bmf = nimfa.Bmf(V, max_iter=10, rank=30, n_run=3, track_factor=True) bmf_fit = bmf()

print('K-L divergence: %5.3f' % bmf_fit.distance(metric='kl'))

sm = bmf_fit.summary() print('Rss: %5.3f' % sm['rss']) print('Evar: %5.3f' % sm['evar']) print('Iterations: %d' % sm['n_iter']) print('Cophenetic correlation: %5.3f' % sm['cophenetic']) W = bmf_fit.basis() print('Basis matrix:\n%s' % W)`

The W matrix was not binary . When i changed V matrix into binary matrix, the w matrix is still not binary matrix. Can someone help me how can get binary matrix.? Thank you!