Skip to main content

Need of clustering; hierarchical vs partitioning; K-means

Short answer

Clustering discovers natural groups; hierarchical builds a tree without k, partitioning needs k. With initial centroids (1,1.5) and (2.5,5.5), final clusters: {1,3,4} centroid (1.50,1.83) and {2,5,6} centroid (3.00,5.07).

Why do we need cluster analysis? Differentiate between hierarchical and partitioning clustering technique. Identify the cluster of the following instances using K-Means clustering algorithm.

InstanceXY
11.01.5
22.55.5
31.51.0
42.03.0
52.53.5
64.06.2

Need for cluster analysis

Cluster analysis groups unlabelled objects so that objects in a cluster are similar and those in different clusters are dissimilar. It is needed because:

  • Large data sets have no class labels; clustering discovers natural groups and the structure of the data (e.g. customer segments for marketing).
  • It summarises and compresses data: each cluster can be represented by its centre.
  • It is a preprocessing step for other methods and helps detect outliers (objects far from every cluster).
  • Applications: image segmentation, document grouping, biology (gene groups), city planning, fraud detection.

Hierarchical vs partitioning clustering

BasisHierarchicalPartitioning
OutputTree of nested clusters (dendrogram)One flat set of k clusters
k required?No; cut the dendrogram at a levelYes, given in advance
ApproachAgglomerative (bottom-up) / divisive (top-down)Iterative relocation of objects (k-means, k-medoids)
Undo stepsA merge or split cannot be undoneObjects can move between clusters
ComplexityAt least O(n²), not for very large dataO(nkt), scalable
ShapeCan find non-spherical clusters (single link)Spherical, similar sized
ExamplesAGNES, DIANA, BIRCHk-means, PAM

K-means on the data (K = 2)

InstanceXY
11.01.5
22.55.5
31.51.0
42.03.0
52.53.5
64.06.2

Assumption: K = 2, and the first two instances are the initial centroids: C1 = (1.0, 1.5) and C2 = (2.5, 5.5). Euclidean distance d = √[(x − cx)² + (y − cy)²].

Iteration 1 (centroids C1 = (1.0, 1.5), C2 = (2.5, 5.5))

Instance(X, Y)d to C1d to C2Cluster
1(1.0, 1.5)0.004.27C1
2(2.5, 5.5)4.270.00C2
3(1.5, 1.0)0.714.61C1
4(2.0, 3.0)1.802.55C1
5(2.5, 3.5)2.502.00C2
6(4.0, 6.2)5.581.66C2

Clusters: C1 = {1, 3, 4}, C2 = {2, 5, 6}. New centroids: C1 = ((1.0 + 1.5 + 2.0)/3, (1.5 + 1.0 + 3.0)/3) = (1.50, 1.83); C2 = ((2.5 + 2.5 + 4.0)/3, (5.5 + 3.5 + 6.2)/3) = (3.00, 5.07).

Iteration 2 (centroids C1 = (1.50, 1.83), C2 = (3.00, 5.07))

Instanced to C1d to C2Cluster
10.604.09C1
23.800.66C2
30.834.33C1
41.272.30C1
51.941.64C2
65.031.51C2

The assignment is unchanged, so the algorithm has converged (the centroids would stay the same).

Answer: Cluster 1 = {instances 1, 3, 4} with centroid (1.50, 1.83); Cluster 2 = {instances 2, 5, 6} with centroid (3.00, 5.07).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Data Mining chapter 5 questions →