Unsupervised Learning
Related: 2. Supervised Learning | 1. Data Exploration and Visualisation | 12. Autoencoders | Artificial Intelligence
Clustering
Clustering is a type of unsupervised learning that groups similar objects together. The training data contains no output labels.
Goals: data reduction, outlier detection, missing value imputation, pattern discovery.
Key principle: maximise within-cluster similarity, minimise between-cluster similarity.
Similarity measures (same as KNN):
- Euclidean distance
- Manhattan distance
Cluster Quality Measures
- Cluster centre — for numeric data, the centre of mass (mean); for nominal data, the mode
- Within-cluster variation (wc) — how compact/tight clusters are
- Between-cluster variation (bc) — distances between different clusters
K-Means Algorithm
- Define the number of clusters
- Choose data objects randomly as initial centroids
- Assign each data object to its nearest centroid
- Recalculate the centroid of each cluster as the mean of its members
- Repeat steps 3–4 until cluster membership no longer changes
Finding optimal — Elbow Method:
Plot within-cluster sum of squares (WCSS) against . The “elbow” point where adding more clusters no longer significantly reduces WCSS is the optimal .
Strengths: Simple, efficient.
Weaknesses: Must specify in advance, sensitive to initialisation, sensitive to noise, struggles with non-globular cluster shapes.
Agglomerative (Hierarchical) Clustering
A bottom-up approach — no need to specify beforehand.
Algorithm:
- Treat all data objects as individual clusters; build an dissimilarity matrix
- While number of clusters > 1:
- Find the pair with minimum distance
- Merge them into a bigger cluster
- Update the distance matrix
- Produces a dendrogram
Measuring distance between clusters:
| Method | Description |
|---|---|
| Single link | Distance between the two closest points |
| Complete link | Distance between the two furthest points |
| Centroid | Distance between cluster centroids |
| Group average | Average of all pairwise distances |
Strengths: Deterministic, multiple clustering versions, no need to specify , can create arbitrary cluster shapes.
Weaknesses: Does not scale well to large datasets.