Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Hu-JIN committed Apr 5, 2022
1 parent 87be771 commit 73e4103
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion musical/refit.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,17 @@ def _get_W_s(W, W_catalog, H_reduced, cos_similarities, thresh_new_sig):
sig_map = H_reduced
return W_s, sig_map

def _clear_W_s(W, W_s, sig_map, min_sum_0p01 = 0.15, min_sig_contrib_ratio = 0.25):
def _clear_W_s(W, W_s, sig_map, min_sum_0p01=0.15, min_sig_contrib_ratio=0.25):
"""
TODO:
1. The 0.01 threshold may need to be adjusted for signature definitions with different numbers of channels.
"""
for i in range(sig_map.shape[1]):
set_to_zero = False
for j in range(sig_map.shape[0]):
fij = sig_map.iat[j,i]
if fij < 1 and fij != 0:
# Scale the signature according to the contribution it makes
contrib = np.dot(W_s[sig_map.index[j]], fij)
sum_above_0p01 = np.sum(contrib[contrib > 0.01])
max_sig_contrib_ratio = max(contrib)/max(W[sig_map.columns[i]])
Expand Down

0 comments on commit 73e4103

Please sign in to comment.