Skip to content

ValueError during run #9

Description

@asmolnicka

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions