k-Means
k-Means Clustering
Say we have points . We want to partition them into sets such that the cost of the partition is minimised, :
Where is the mid-point of each cluster, i.e. .
Where is the squared L2 norm (squared Euclidian distance).
Link to original
k-Means (Algorithm)
To perform k-Means Clustering:
- Select points as initial cluster means (cluster centroids)
- Assign each point in the data to the cluster with the closest centroid.
- When all points have been assigned, recalculate the positions of the centroids.
- Repeat steps and until centroids no longer change.
Link to original
Example of lucky initialisation (optimal cluster)
Example of arbitrarily bad cluster (sub-optimal clusters)
We can solve this issue by using k-Means++.
k-Means++
k-Means++ Algorithm
We can solve arbitrarily bad initialisations of clusters and generally find a solution much faster by using k-Means++. It can be shown that the approximation factor is at most .
Link to original
- Set the first centre to be one of the input points chosen uniformly at random.
- For cluster to :
- For each point , compute the distance to the nearest centre, i.e. calculate
- Open a new centre at a point using the weighted probability distribution that is proportional to , that is:
- Continue with k-Means.
k-Median
k-Median Clustering
Say we have points . We want to partition them into sets such that the cost of the partition is minimised, :
Where is the mid-point of each cluster, i.e. . Where is the L1 norm (Manhattan distance).
Link to original
Elbow method
Elbow method (clustering)
The elbow method is a heuristic in determining the number of clusters in a data set. We plot the K-mean score (% of variance explained) against the number of clusters and picking the “elbow of the curve” as the number to use.
Pick the that maximises where is the cost of clustering with clusters. are ruled out as they result in trivial clusters.
Link to original
Hierarchical Clustering
Hierarchical Clustering
Hierarchical clustering results in a series of clustering results:
- the results start off with each object in their own cluster and end with all of the objects in the same cluster
- the intermediate clusters are created by a series of merges
- the resultant tree-like structure is called a dendrogram
You build a binary tree of the data that successively merges similar groups of points, visualising this tree provides a useful summary of the data.
This resolves an issue with flat clustering (k-Means) where structure is lost.
Link to original
Agglomerative clustering (bottom up)
Agglomerative Clustering
Initially place each data point in its own clusters, repeatedly merge most similar clusters.
We create a graph, an edge can mean similarity or dissimilarity (we only look at similarities). A high similarity value means that the corresponding two nodes are very similar and should be in the same cluster.
Link to original
Similarity (Agglomerative Clustering)
The similarity between two clusters and is
Link to original
[animate slides 5-7]
The obtained merges can be represented in a dendogram:

Divisive clustering (top down)
Divisive Clustering
In divisive clustering, we split using bisection -means (or sparsest cut), recursing on each part. In effect, working our way from the top down through the graph.
Link to original
Divisive Clustering Algorithm
Link to original
- Find a partition of the input similarity graph (or set of points) and:
- Split using bisection -means
- Split using sparsest cut
- Recurse on each part
- Builds cluster-tree top-down
Sparsest Cut
Sparsity of a cut
Given a graph with nodes and edges in . The sparsity of a cut is given by:
Where is the sum of weights of edges crossing the cut. Here , so is the min. number of elements of both sets.
Link to original
Sparsest cut
The sparsest cut of a graph is given by that minimises , i.e. $$ \phi(S^*) = \underset{S}{\text{min}} \phi(S)
Link to original








