def METHOD_NAME(self, A):
    if A.shape[0] * self.pval < 6:
        pval = 6. / A.shape[0]
    else:
        pval = self.pval
    n_elems = int((1 - pval) * A.shape[0])
    # For each row in a affinity matrix
    for i in range(A.shape[0]):
        low_indexes = np.argsort(A[i, :])
        low_indexes = low_indexes[0:n_elems]
        # Replace smaller similarity values by 0s
        A[i, low_indexes] = 0
    return A