Data Warehousing and Data Mining · Unit 7 · 8 hrs
Cluster Analysis
Exam-focused notes for Cluster Analysis (Data Warehousing and Data Mining, CSC420): what the TU syllabus asks and how it has actually been tested, with 9 solved past questions from this unit.
Cluster Analysis in short
Clustering groups a set of objects into classes of similar objects without being told the classes in advance, which is what makes it an unsupervised technique. This unit works through the distance measures clustering relies on, then traces k-means, k-means++, k-medoids, single-linkage hierarchical clustering and DBSCAN iteration by iteration on small concrete point sets, checking every distance and every centroid update along the way.
What this unit covers
- Types of data in cluster analysis
- Similarity and dissimilarity between objects
- Clustering techniques: Partitioning (k-means, k-means++, Mini-Batch k-means, k-medoids)
- Hierarchical (Agglomerative and Divisive)
- Density based (DBSCAN)
- Outlier analysis
Clustering techniques
2081 · 5 marks
Using k-means++ algorithm and Euclidean distance, find the initial 3 cluster centroids from A1 = (3, 11), A2 = (3, 6), A3 = (9, 5), A4 = (6, 9), A6 = (7, 5), A7 = (2, 3), A8 = (5, 10). Choose (3, 11) as one of the initial centroids. [5]
Show solved answerHide answer
K-Means++ Initial Centroid Selection
Given
Data points:
| Point | Coordinates |
|---|---|
| A1 | (3, 11) |
| A2 | (3, 6) |
| A3 | (9, 5) |
| A4 | (6, 9) |
| A6 | (7, 5) |
| A7 | (2, 3) |
| A8 | (5, 10) |
Number of clusters: $k = 3$ First centroid (given): $C_1 = (3, 11)$
Solution
K-Means++ Rule
- First centroid is fixed as $C_1 = (3,11)$.
- For each point compute $D^2$ = squared Euclidean distance to the nearest chosen centroid.
- Choose the point with the largest $D^2$ (highest selection probability) as the next centroid.
Selecting $C_2$: distances to $C_1 = (3,11)$
$$D^2 = (x-3)^2 + (y-11)^2$$
| Point | Calculation | $D^2$ |
|---|---|---|
| A2 (3,6) | $0 + 25$ | 25 |
| A3 (9,5) | $36 + 36$ | 72 |
| A4 (6,9) | $9 + 4$ | 13 |
| A6 (7,5) | $16 + 36$ | 52 |
| A7 (2,3) | $1 + 64$ | 65 |
| A8 (5,10) | $4 + 1$ | 5 |
Total $= 25+72+13+52+65+5 = 232$
Probability $= D^2 / 232$:
| Point | P |
|---|---|
| A2 | 0.108 |
| A3 | 0.310 |
| A6 | 0.224 |
| A7 | 0.280 |
| A4 | 0.056 |
| A8 | 0.022 |
Largest $D^2$ is A3 (72).
$$\boxed{C_2 = (9, 5)}$$
Selecting $C_3$: nearest distance to ${C_1, C_2}$
$D^2(C_2)$ with $C_2 = (9,5)$:
| Point | $D^2(C_1)$ | $D^2(C_2)$ | $\min$ |
|---|---|---|---|
| A2 (3,6) | 25 | $36+1=37$ | 25 |
| A4 (6,9) | 13 | $9+16=25$ | 13 |
| A6 (7,5) | 52 | $4+0=4$ | 4 |
| A7 (2,3) | 65 | $49+4=53$ | 53 |
| A8 (5,10) | 5 | $16+25=41$ | 5 |
Total $= 25+13+4+53+5 = 100$
Probability $= \min D^2 / 100$:
| Point | P |
|---|---|
| A2 | 0.25 |
| A4 | 0.13 |
| A6 | 0.04 |
| A7 | 0.53 |
| A8 | 0.05 |
Largest $\min D^2$ is A7 (53).
$$\boxed{C_3 = (2, 3)}$$
Final Result
The 3 initial centroids chosen by K-Means++ are:
| Centroid | Coordinates |
|---|---|
| $C_1$ | (3, 11) |
| $C_2$ | (9, 5) |
| $C_3$ | (2, 3) |
2081 · 5 marks
Differentiate between k-means and k-medoids clustering algorithm. [5]
2080 · 5 marks
How K-medoids clustering differs from K-means clustering? Divide the following data points into two clusters using kmedoids algorithm. Show computation up to 3 iterations. {(70,85), (65,80), (72,88), (75,90), (60,50), (64,55), (62,52), (63,58)}. [5]
2079 · 5 marks
Discuss the concept of K-means++ and Mini-batch K-means algorithm. [5]
2078 · 5 marks
Apply K(=2)-Means algorithm over the data (185, 72), (170, 56), (168, 60), (179, 68), (182, 72), (188, 77) up to two iterations and show the clusters. Initially choose first two objects as initial centroids. [5]
Density based
2078 · 10 marks
How do you compare two classifiers? Given the points A(3,7), B(4,6), C(5,5), D(6,4), E(7,3), F(6,2), G(7,2) and H(8,4), find the core points, border points and outliers using DBSCAN. Take Eps 2.5 and MinPts = 3.[10]
Hierarchical
2079 · 5 marks
What are two categories of hierarchical clustering? Divide the following data points into two clusters using agglomerative clustering. { (2,10), (2,5), (8,4), (5,8), (7,5), (6,4) } [5]
Show solved answerHide answer
Hierarchical Clustering: Two Categories and Agglomerative Example
Given
Data points to cluster:
- P1 = (2, 10)
- P2 = (2, 5)
- P3 = (8, 4)
- P4 = (5, 8)
- P5 = (7, 5)
- P6 = (6, 4)
Target: 2 clusters. Linkage method not specified; I will use single linkage (minimum distance) as is standard for this textbook problem.
Solution
Two Categories of Hierarchical Clustering
-
Agglomerative (Bottom-Up): Each object starts as its own cluster. At each step the two closest clusters are merged, continuing until all objects form one cluster (or the desired number is reached).
-
Divisive (Top-Down): All objects start in a single cluster, which is repeatedly split into smaller clusters until each object is alone (or the desired number is reached).
Distance Formula (Euclidean)
$$d(P_i, P_j) = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$$
Initial Distance Matrix
| P1 | P2 | P3 | P4 | P5 | P6 | |
|---|---|---|---|---|---|---|
| P1 | 0 | 5.00 | 9.22 | 5.39 | 9.06 | 9.22 |
| P2 | 5.00 | 0 | 6.08 | 4.24 | 5.00 | 4.12 |
| P3 | 9.22 | 6.08 | 0 | 5.83 | 2.24 | 2.00 |
| P4 | 5.39 | 4.24 | 5.83 | 0 | 3.61 | 5.00 |
| P5 | 9.06 | 5.00 | 2.24 | 3.61 | 0 | 1.41 |
| P6 | 9.22 | 4.12 | 2.00 | 5.00 | 1.41 | 0 |
Sample checks:
- $d(P5,P6)=\sqrt{1^2+1^2}=1.41$ (minimum)
- $d(P3,P6)=\sqrt{2^2+0^2}=2.00$
- $d(P3,P5)=\sqrt{1^2+1^2}=2.24$
Step A: Merge closest pair
Minimum = 1.41 (P5, P6). Merge → C1 = {P5, P6}
Clusters: {P1}, {P2}, {P3}, {P4}, {P5,P6}
Step B: Recompute (single linkage)
- $d({P5,P6},P1)=\min(9.06,9.22)=9.06$
- $d({P5,P6},P2)=\min(5.00,4.12)=4.12$
- $d({P5,P6},P3)=\min(2.24,2.00)=2.00$ ← minimum overall
- $d({P5,P6},P4)=\min(3.61,5.00)=3.61$
Merge P3 → C1 = {P3, P5, P6}
Clusters: {P1}, {P2}, {P4}, {P3,P5,P6}
Step C: Recompute
- $d({P3,P5,P6},P1)=\min(9.22,9.06,9.22)=9.06$
- $d({P3,P5,P6},P2)=\min(6.08,5.00,4.12)=4.12$
- $d({P3,P5,P6},P4)=\min(5.83,3.61,5.00)=3.61$ ← minimum overall
(Others: $d(P1,P2)=5.00,\ d(P1,P4)=5.39,\ d(P2,P4)=4.24$)
Merge P4 → C1 = {P3, P4, P5, P6}
Clusters: {P1}, {P2}, {P3,P4,P5,P6}
Step D: Recompute
- $d({P3,P4,P5,P6},P1)=\min(9.22,5.39,9.06,9.22)=5.39$
- $d({P3,P4,P5,P6},P2)=\min(6.08,4.24,5.00,4.12)=4.12$
- $d(P1,P2)=5.00$
Minimum = 4.12 (between big cluster and P2). Merge P2 → C1 = {P2, P3, P4, P5, P6}
Clusters: {P1}, {P2,P3,P4,P5,P6}
Final Result (2 clusters)
We stop when exactly two clusters remain:
$$\boxed{\text{Cluster 1} = {P1} = {(2,10)}}$$ $$\boxed{\text{Cluster 2} = {P2,P3,P4,P5,P6} = {(2,5),(8,4),(5,8),(7,5),(6,4)}}$$
Point P1 = (2,10) is the outlier that separates last, forming its own cluster; all other points group together.
Types of data in cluster analysis
2075 · 5 marks
What is the purpose of cluster analysis in data mining? Explain. [5]
Make Unit 7 stick
Practice CSC420 with flashcards & quizzes