mims-harvard / nimfa

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

Unhashable type: 'matrix' when trying to use purity function #47

Closed zclandry closed 5 years ago

zclandry commented 5 years ago

When I try to use the purity function with a fitted nmf model, using a list of numbers as the membership list, I receive the following error:

nmf.purity(classes) Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2878, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in nmf.purity(classes) File "/usr/local/lib/python2.7/dist-packages/nimfa/models/nmf.py", line 388, in purity [dmbs.setdefault(mbs[i], set()).add(i) for i in range(len(mbs))] TypeError: unhashable type: 'matrix'

the nmf model was fitted using the Bd function. "classes" is a plain python list. The documentation asks for a list. Does it need something else? How can this be fixed?

marinkaz commented 5 years ago

Thank you, this is fixed now.

zclandry commented 5 years ago

Could you update the version from PyPI to reflect this? Also, there seems to be a similar problem with the "entropy" function. See below for details:

nmf.entropy(classes) Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py", line 3326, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in nmf.entropy(classes) File "/usr/local/lib/python3.7/dist-packages/nimfa/models/nmf.py", line 251, in entropy [dmbs.setdefault(mbs[i], set()).add(i) for i in range(len(mbs))] File "/usr/local/lib/python3.7/dist-packages/nimfa/models/nmf.py", line 251, in [dmbs.setdefault(mbs[i], set()).add(i) for i in range(len(mbs))] TypeError: unhashable type: 'matrix'

marinkaz commented 5 years ago

The new version is available on PyPI. It fixes of entropy function and includes a few other enhancements. Thanks!