Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate code #10

Open
Kim-SeongCheol opened this issue Dec 11, 2019 · 0 comments
Open

Duplicate code #10

Kim-SeongCheol opened this issue Dec 11, 2019 · 0 comments

Comments

@Kim-SeongCheol
Copy link

I think that there is duplicate codes in _labels_inertia_precompute_dense function.
initial_assignment function and below for loop is doing same thing.

labels, mindist = initial_assignment(labels, mindist, n_samples, all_distances, max_cluster_size)
all_points = np.arange(n_samples)

for point in all_points:
    for point_dist in get_best_point_distances(point, all_distances):
        cluster_id, point_dist = point_dist
        # initial assignment
         if not is_cluster_full(cluster_id, max_cluster_size, labels):
            labels[point] = cluster_id
            mindist[point] = point_dist
            break

Following code is initial_assignment function.

def initial_assignment(labels, mindist, n_samples, all_distances, max_cluster_size):
    """Initial assignment of labels and mindist"""
    all_points = np.arange(n_samples)
    for point in all_points:
        for point_dist in get_best_point_distances(point, all_distances):
            cluster_id, point_dist = point_dist
            # initial assignment
            if not is_cluster_full(cluster_id, max_cluster_size, labels):
                labels[point] = cluster_id
                mindist[point] = point_dist
                break
    return labels, mindist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant