Centroid-based Clustering

What is Centroid-based Clustering

Centroid-based methods group data points together based on the proximity of data points to the centroid (cluster center).

Measure proximity

Examples

Comparison of centroid-based methods

Method Best for Center type Distance / similarity Require choosing K Main weakness
K-Means numerical data mean point Euclidian distance Yes sensitive to outliers
K-Medoids numerical or custom-distance data real data point many distance metrics Yes slower than K-Means
K-modes categorical data mode Hamming / matching dissimilarity Yes only for categorical data
K-prototype mixed numerical + categorical data mean + mode Euclidian + categorical mismatch Yes needs weighting between feature types
Mean Shift unknown number of clusters dense region / mode distance + bandwidth No sensitive to bandwidth and slower on large datasets
Fuzzy Clustering overlapping clusters fuzzy centroid usually Euclidian distance Yes harder to interpret than hard clustering

General tips during use

Choose the right number of clusters

Measure the separability between clusters: Silhouette Method

Watch out for scale and high dimensionality

K-Means Clustering

How it works

  1. Choose the number K of clusters
  2. Select at random K points, the centroids (not necessarily from your dataset)
  3. Assign each data point to the closest centroid => that forms K clusters
  4. Compute and place the new centroid of each cluster
  5. Reassign each data point to the new closest centroid
  6. Repeat until your model is ready (i.e. cost function reaches minimum)
Important

K-Means Clustering vs. KNN (K-Nearest Neighbor)

K-means clustering KNN
k = number of clusters k = number of nearest neighbors
unsupervised learning supervised learning
clustering regression & classification
to optimize, use elbow method to optimize, use cross validation & confusion matrix

K-Means-specific tips

Random Initialisation trap

K-modes & K-prototype

Why K-modes or K-prototype

How it works

K-modes

K-prototype

K-Medoids

Why K-Medoids

How it works

  1. Choose the number K of clusters
  2. Select K data points as the initial medoids
  3. Assign each data point to the closest medoid
  4. For each cluster, try replacing the current medoid with another point in the same cluster
  5. Keep the replacement if it reduces the total distance between points and their medoid
  6. Repeat until the medoids no longer change
Note

The objective is to minimize the total distance between each data point and the medoid of its cluster.

Common algorithm: PAM (Partitioning Around Medoids)

Mean Shift

Why Mean Shift

How it works

  1. Choose a bandwidth, which controls the search radius
  2. For each point, look at nearby points within the bandwidth
  3. Shift the point toward the mean of nearby points
  4. Repeat until points converge to dense regions
  5. Points that converge to the same region are grouped into the same cluster
Note

The bandwidth parameter is very important: too small can create too many clusters, too large can merge different clusters.

Fuzzy Clustering

Why Fuzzy Clustering

How it works

  1. Choose the number K of clusters
  2. Initialize K cluster centers
  3. Assign each data point a membership score for each cluster
  4. Update cluster centers based on the weighted membership scores
  5. Repeat until the cluster centers or membership scores stop changing
Example

A customer can be 70% in one segment and 30% in another segment instead of belonging fully to only one group.