maxfuse.utils.shrink_towards_centroids

maxfuse.utils.shrink_towards_centroids(arr, labels, wt)[source]

For each row of arr, shrink it towards its cluster centroid by taking wt*raw_data + (1-wt)*centroid

Parameters:
  • arr (np.array of shape (n_samples, n_features)) – Data matrix

  • labels (np.array of shape (n_samples,)) – Cluster labels

  • wt (float) – Weight for shrinkage

Returns:

denoised_arr (np.array of shape (n_samples, n_features)) – Original array after centroid shrinkage