def _log_normalize(X):
 X = make_nonnegative(X, min_value=1)
 if issparse(X):
  raise ValueError('Cannot compute log of a sparse matrix, because log(x) diverges to -infinity as x goes to 0.')
 L = np.log(X)
 row_avg = L.mean(axis=1)[:, np.newaxis]
 col_avg = L.mean(axis=0)
 avg = L.mean()
 return (((L - row_avg) - col_avg) + avg)

def _log_normalize ( X ) : X = make_nonnegative ( X , min_value = 1 ) if issparse ( X ) : raise ValueError ( 'Cannot compute log of a sparse matrix, because log(x) diverges to -infinity as x goes to 0.' ) L = np . log ( X ) row_avg = L . mean ( axis = 1 ) [ : , np . newaxis ] col_avg = L . mean ( axis = 0 ) avg = L . mean ( ) return ( ( ( L - row_avg ) - col_avg ) + avg )
normalize x according to klugers log-interactions scheme .