K-Means Clustering Demo

Overview

The K-Means Clustering Demo provides an interactive step-by-step visualization of the k-means algorithm. Watch how the algorithm iteratively assigns points to clusters and updates centroids until convergence. Experiment with different values of k, observe the within-cluster sum of squares (WCSS), and use the elbow method to find the optimal number of clusters. This tool makes the abstract concept of unsupervised learning tangible and intuitive.

Open in new tab

Tips

  • Start with k=3 to see clear cluster formation, then experiment with other values
  • Click “Step” to manually advance through iterations and observe the algorithm’s mechanics
  • Watch how centroids move toward the center of their assigned points after each iteration
  • Use “Auto Run” to see the full convergence animation
  • The WCSS (within-cluster sum of squares) decreases with each iteration and levels off at convergence
  • Try the elbow method plot to find the optimal k - look for the “elbow” where WCSS stops decreasing rapidly
  • Reset with new centroids to see different initialization can lead to different local optima
  • Generate new data to experiment with different cluster patterns (blobs, circles, moons)
  • Notice how k-means creates spherical clusters - it struggles with non-spherical shapes