MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / assign_clusters

Function assign_clusters

machine_learning/k_means_clust.py:83–92  ·  view source on GitHub ↗
(data, centroids)

Source from the content-addressed store, hash-verified

81
82
83def assign_clusters(data, centroids):
84 # Compute distances between each data point and the set of centroids:
85 # Fill in the blank (RHS only)
86 distances_from_centroids = centroid_pairwise_dist(data, centroids)
87
88 # Compute cluster assignments for each data point:
89 # Fill in the blank (RHS only)
90 cluster_assignment = np.argmin(distances_from_centroids, axis=1)
91
92 return cluster_assignment
93
94
95def revise_centroids(data, k, cluster_assignment):

Callers 1

kmeansFunction · 0.85

Calls 1

centroid_pairwise_distFunction · 0.85

Tested by

no test coverage detected