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

Replace cSNMF.py to change tail_cutoff to 0.4 and remove padding and default...

Replace cSNMF.py to change tail_cutoff to 0.4 and remove padding and default beta value to len(D.T)//2
parent ee4b9b21
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@ def impose_L1_constraint(W, H):
def axe_H(H, tail_cutoff = 0.25):
def axe_H(H, tail_cutoff = 0.4):
H2 = H.copy()
for i, column in enumerate(H.T):
sorted_column = sorted(column)
......@@ -77,7 +77,6 @@ def factorize(data_array,
seed_H = None,
log = logger,
debug = False,
pad_value = 10**(-6),
axing = True):
log.info('Rank= %s, Threshold= %s', rank, threshold)
......@@ -85,20 +84,16 @@ def factorize(data_array,
D = np.nan_to_num(data_array)
eta = D.max()
if beta is None:
beta = np.nanmean(data_array)
beta = len(D.T)//2
global NONZEROS
NONZEROS = ~np.isnan(data_array)
JNN = np.ones((rank, rank))
def padding(A, pad_value):
return A + pad_value
def update_W(D, W, H):
Term_1 = D @ H.T
Term_2 = N(W @ H) @ H.T + eta*W
W = m(W, Term_1)/Term_2
W = padding(W, pad_value = pad_value)
return W
......@@ -106,7 +101,6 @@ def factorize(data_array,
Term_3 = W.T @ D
Term_4 = W.T @ N(W @ H) + beta*(JNN @ H)
H = m(H, Term_3)/Term_4
H = padding(H, pad_value = pad_value)
return H
......@@ -177,8 +171,8 @@ def factorize(data_array,
results = results.append(dict(zip(column_names, column_values)), ignore_index = True)
W, H = impose_L1_constraint(W, H)
if axing:
W, H = impose_L1_constraint(W, H)
W, H = sort_WH(W, H)
error = calculate_error(D, W, H)
......
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