Algorithm · Tubi · Medium
Implement a K-Means clustering algorithm from first principles. The algorithm receives a real-valued data matrix X with shape (n_samples, n_features) and an integer k representing the desired number of clusters. It must choose k initial centroids, assign every sample to the centroid with the smallest squared Euclidean distance, recompute each centroid as the mean of the samples assigned to it, and repeat this assign-update cycle until one of these conditions is met: the…
Checking your access…