Skip to content
Snippets Groups Projects
Commit bfce6ad7 authored by yager2's avatar yager2
Browse files

Changed factorize to return error. The error value was being lost and could...

Changed factorize to return error.  The error value was being lost and could not be recalculated.  Global problem?
parent 0fd132f3
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ def impose_L1_constraint(W, H):
def axe_H(H, tail_cutoff = 0.25):
H2 = H.copy()
for i, column in enumerate(H.T):
for i, column in enumerate(H2.T):
sorted_column = sorted(column)
cumulative_sum = it.accumulate(sorted_column)
kill_count = sum(list(cumulative_sum) < tail_cutoff*sum(column))
......@@ -51,15 +51,14 @@ def sort_WH(W, H):
H2 = axe_H(H)
weights = H2/sum(H2)
signature_popularities = sum(weights.T)
signature_popularities = sorted(enumerate(signature_popularities), key = lambda x : x[1], reverse=True)
signature_popularities = sorted(enumerate(signature_popularities), key = lambda x : x[1])
signature_popularities.reverse()
signature_popularities
W2 = W.copy()
H3 = H2.copy()
for i in range(len(signature_popularities)):
W2[:, i] = W[:, signature_popularities[i][0]]
H3[i] = H2[signature_popularities[i][0]]
assert ( np.linalg.norm(W@H2 - W2@H3) / np.linalg.norm(W@H2) ) < 0.01:
log.critical('Sorting is not working correctly')
return W2, H3
return W2, H3
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment