K-Means: centroid update
Beginner classical-mlunsupervisedclusteringkmeans
Implement:
def kmeans_update_centroids(input, assignments, centroids) -> np.ndarray:
"""Returns shape (k, n_features): each centroid moved to the mean of its assigned points."""
- A cluster with zero points assigned to it keeps its old centroid unchanged, don't average an empty group.