Skip to content
Quantoros

How to select K for K-means?

Classic MLLevel: IntermediateClustering

How to select K for K-means?

Hints
  • How does this method define distance and cluster shape?
  • Consider noise, the number of groups and feature scaling.

Answer

  • Domain knowledge, i.e. an expert knows the value of k
  • Elbow method: compute the clusters for different values of k, for each k, calculate the total within-cluster sum of square, plot the sum according to the number of clusters and use the band as the number of clusters.
  • Average silhouette method: compute the clusters for different values of k, for each k, calculate the average silhouette of observations, plot the silhouette according to the number of clusters and select the maximum as the number of clusters.

Source and licence: Alexey Grigorev & contributors — Data Science Interviews · CC-BY-4.0

Related questions