Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError during run #9

Open
asmolnicka opened this issue Sep 6, 2023 · 0 comments
Open

ValueError during run #9

asmolnicka opened this issue Sep 6, 2023 · 0 comments

Comments

@asmolnicka
Copy link

When I run the code:

nmf_cm = StandardNmf(pd.DataFrame(data_tfidf), k = 20)
nmf_cm.run(iterations = 1000, trials = 20)

I get the following error:

ValueError
30 nmf_cm = StandardNmf(pd.DataFrame(data_tfidf), k = k)
---> 31 nmf_cm.run(iterations = 100, trials = 20, verbose = 0)
32 nmf_cm.calc_consensus_matrices()
33 nmf_cm.calc_cophenetic_correlation()

File ...\bignmf\models\snmf\snmf_base.py:52, in SnmfBase.run(self, trials, iterations, verbose)
50 print("\tTrial: %i completed with Error: %f " % (i, self.error))
51 # Normalization
---> 52 self.consensus_matrix_w = self.reorder_consensus_matrix(self.consensus_matrix_w / trials)
53 self.consensus_matrix_h = self.reorder_consensus_matrix(self.consensus_matrix_h / trials)
54 # Converting values to DataFrames

File ...\bignmf\models\nmf.py:69, in NmfBase.reorder_consensus_matrix(M)
67 M = pd.DataFrame(M)
68 Y = 1 - M
---> 69 Z = linkage(squareform(Y), method='average')
70 ivl = leaves_list(Z)
71 ivl = ivl[::-1]

File ...\scipy\spatial\distance.py:2354, in squareform(X, force, checks)
2352 raise ValueError('The matrix argument must be square.')
...
2436 'be zero.') % name)
2437 else:
2438 raise ValueError('Distance matrix diagonal must be zero.')

ValueError: Distance matrix 'X' diagonal must be zero.

My input is TFIDF data and there are no negative elements in it. Is there something wrong in the implementation of the function or am I making a mistake?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant