Sources: 6_Clustering.pdf; past questions: QP_DM_SEM_25.pdf, pqy26.pdf. Slide numbers refer to PDF pages.
Study distance measures first, then work through k-means, hierarchical linkage and DBSCAN. PAM and k-medoids are marked as not present in the syllabus. The worked PYQs include the data and explicit assumptions, because a numerical clustering answer depends on the distance, starting centres, linkage and stopping rule.
Important: All clustering topics and questions in this note are important, including distance measures, k-means and its modifications, hierarchical clustering, DBSCAN, CF-trees and CLIQUE.
Not present: PAM / k-medoids and the PAM portions of mixed questions are not present in the syllabus.
1. Clustering fundamentals — ⭐ IMPORTANT: SHORT THEORY
Cluster analysis groups objects so objects in the same cluster are relatively similar and objects in different clusters are relatively dissimilar. It is generally unsupervised: the training labels required by classification are not given. Uses include customer segmentation, grouping documents, biological analysis, spatial patterns, image segmentation and detecting unusual activity.
An outlier is an object substantially different from the bulk of the data; it may be an error or a meaningful rare event, such as fraud. What counts as a good clustering depends on the data representation, similarity measure and objective. There may be multiple valid answers.
- Partitional: produces one division into clusters, e.g. k-means.
- Hierarchical: nested clusters represented by a tree/dendrogram.
- Exclusive versus overlapping: an object belongs to one cluster versus possibly several.
- Complete versus partial: every object is assigned versus some are left unassigned as noise.
- Crisp versus fuzzy: membership is binary versus graded.
2. Similarity, distance and attribute types — ⭐ IMPORTANT: DISTANCES AND ATTRIBUTE TYPES
For numeric vectors with attributes, Minkowski distance is
gives Manhattan distance and Euclidean distance. Example: between (1,2) and (4,6), Manhattan , Euclidean . Scaling matters: rupee values can dominate page counts, so standardize when units or ranges are not meant to imply importance. A metric obeys non-negativity, identity, symmetry and triangle inequality.
| Attribute | Common treatment |
|---|---|
| Interval/numeric | Normalize or standardize, then use Euclidean/Manhattan distance. |
| Symmetric binary | Both 0 and 1 are equally important; simple matching counts mismatches. |
| Asymmetric binary | Joint absences are unimportant; Jaccard dissimilarity ignores them. |
| Nominal | Simple mismatch fraction , where is matches. |
| Ordinal | Convert ranks to scaled values, e.g. , then compare. |
| Ratio | May use a log transform for positive highly skewed values, depending on the domain. |
| Mixed | Combine per-attribute dissimilarities with suitable weights and handle missing values. |
For binary attributes let be matching and mismatching counts. Symmetric binary dissimilarity is . Jaccard dissimilarity is when the denominator is nonzero.
3. k-means — ⭐ IMPORTANT: ALGORITHM, NUMERICALS AND MODIFICATIONS
Given , k-means partitions numeric points around centroids, the coordinate-wise means of their assigned points.
- Choose initial centroids.
- Assign every point to the nearest centroid.
- Recompute each centroid as the mean of its assigned points.
- Repeat assignment and recomputation until assignments or centroids stop changing; specify how an empty cluster is reinitialized.
For conventional Euclidean k-means the objective is sum of squared errors:
Example: points 1, 2, 8, 9, , initial centres 1, 8. Assignment is {1,2}, {8,9}; new means are 1.5, 8.5. Reassignment is unchanged. SSE .
Different initial centres can lead to different local solutions. Use several initializations or k-means++ and compare SSE; an elbow plot of SSE versus is a heuristic, not proof of the correct . k-means assumes a specified , is sensitive to outliers and scale, and is often poor for non-globular clusters, different densities or sizes. It requires a meaningful mean. More clusters never increase the optimal SSE, so compare with the same or a suitable complexity criterion.
⭐ IMPORTANT - k-means modification: Bisecting k-means. start with one cluster, choose one cluster to split into two by k-means, repeat until clusters exist. Multiple candidate splits may be tried and selected by SSE.
2025 CO5(a) (2+3+5 marks): What is the goal of clustering? What is outlier detection? Suppose that the data mining task is to cluster the following ten books into three clusters, the distance function is Manhattan. Assign record 1, 2, and 3 as the centroid of each cluster respectively. Use the k-means algorithm to show the final three clusters.
The original question and all ten book records are shown below.
The goal of clustering is to group objects so that objects within the same cluster are more similar to one another than they are to objects in other clusters. Outlier detection identifies objects that differ markedly from the majority; such objects may be errors or meaningful unusual cases.
The paper specifies Manhattan distance and initial centroids equal to records 1, 2 and 3. For a book and centroid , calculate . Assign each record to the closest centroid and then calculate each centroid as the arithmetic mean of its members.
Initial centroids: , and . For example, record 5 (170,250) has distances , and , respectively, so it joins .
| Iteration | Cluster 1 records | Cluster 2 records | Cluster 3 records |
|---|---|---|---|
| First assignment | 1, 10 | 2, 5, 6, 7, 9 | 3, 4, 8 |
| After first update | 1, 5, 10 | 2, 6, 7, 9 | 3, 4, 8 |
| Next assignment | 1, 5, 10 | 2, 6, 7, 9 | 3, 4, 8 |
After the first assignment, the new centres are , and . For example, the new first centre is . Record 5 is now 123.5 from the first centre, 225.6 from the second and approximately 513.67 from the third, so it moves to cluster 1.
After recomputing, the final centres are , and . The next assignment does not change, so the algorithm stops with the clusters in the final row.
Convention: Standard k-means uses Euclidean distance with arithmetic means. The paper explicitly asks for Manhattan distance; the calculation above follows that instruction while retaining mean updates. Coordinate-wise medians instead minimize the Manhattan objective, giving k-medians. The raw values are used because the paper does not specify scaling.
2022 CO2 Q2(a)(i): The given table consists of twelve points in 2-D. Find the best possible two clusters using k-means and k-medoids.
Assume unscaled Euclidean distance and ; the paper does not specify initialization. Number the points as in the table.
⭐ IMPORTANT — k-means: Choose initial centres and . Assign each point to its nearest centre. The first assignment is and . Their means are and . Reassignment leaves the memberships unchanged, so the algorithm stops. Other initial centres can give another local solution.
⛔ NOT PRESENT — k-medoids: Minimizing total Euclidean distance over all 66 possible pairs gives medoids and , with total cost approximately . Their clusters are and , respectively. has the same coordinates as and is an equivalent medoid choice. The 2021 sets contain separate ten-point questions; their data should not be substituted for this table.
Set 1 and Set 4: Each asks for two clusters using k-means on its own ten-point table.
Assume Euclidean distance, unscaled coordinates, arithmetic-mean updates and . The paper does not specify the initial centres.
Set 1: Take and as initial centres. Nearest-centre assignment gives and . Recompute the means:
The next assignment is unchanged. The final SSE is .
Set 4: Start at and . The first assignment is , . Their means are and . Reassignment is unchanged, and SSE is approximately . Other initial centres can converge to another local solution.
4. k-medoids and PAM — ⛔ NOT PRESENT: PAM / K-MEDOIDS
A medoid is an actual data object chosen as a cluster representative. PAM (Partitioning Around Medoids) selects medoids, assigns each object to its nearest medoid, then considers swaps of a medoid with a non-medoid. Accept a swap that lowers the total dissimilarity, and repeat until no improving swap exists. Specify the distance and initial medoids; a local optimum need not be global.
Compared with k-means, PAM’s representative is a real observation, it works with general dissimilarities, and it is less sensitive to extreme points. It usually costs more computationally, especially on large datasets. Scaling and distance choice still matter.
2026 CO5(a) (3+7 marks): What are the advantages of PAM algorithm over k-means algorithm? The given table consists of twelve objects (i.e., points) in 2-D system. Find two best possible clusters formed by the objects using the k-medoids algorithms.
The complete temperature and ice-cream sales table is shown in the paper image below.
PAM has three advantages over k-means: its cluster representative is an actual data object, it can use general dissimilarity measures, and it is less sensitive to extreme values than a mean-based centre. Its main trade-off is greater computation.
The question does not specify distance or scaling. Assume unscaled Euclidean distance, , and choose the two observed medoids that minimize the sum of distances from every point to its nearer medoid. Examining all pairs gives the best pair as record 9 (24,180) and record 10 (36,350).
| Record | Distance to 9 | Distance to 10 | Assignment |
|---|---|---|---|
| 1 | 60.30 | 230.70 | 9 |
| 2 | 30.27 | 200.64 | 9 |
| 3 | 15.13 | 185.53 | 9 |
| 4 | 140.36 | 30.07 | 10 |
| 5 | 220.58 | 50.16 | 10 |
| 6 | 30.07 | 140.36 | 9 |
| 7 | 60.13 | 110.29 | 9 |
| 8 | 120.27 | 50.16 | 10 |
| 9 | 0 | 170.42 | 9 |
| 10 | 170.42 | 0 | 10 |
| 11 | 80.22 | 90.20 | 9 |
| 12 | 190.52 | 20.10 | 10 |
For example, the distance from record 11 (30,260) to record 9 is ; its distance to record 10 is , so it joins medoid 9.
The final clusters are {1, 2, 3, 6, 7, 9, 11} and {4, 5, 8, 10, 12}. The total distance to the nearer medoid is approximately 426.61. Exhaustive comparison establishes the global best pair under these assumptions. Ordinary PAM instead starts with medoids and accepts improving swaps until none remains; it can stop at a local optimum. Different scaling or distance can produce a different result.
Find two clusters using k-medoids for the ten points shown in each set’s table. State the distance and starting medoids, and show assignment and swap costs.
For Set 2, assume Euclidean distance without scaling and seek the global minimum sum of distances to the nearest medoid. Exhaustively checking all pairs gives medoids and , total cost approximately . duplicates and is an equivalent medoid.
| Cluster | Medoid | Assigned records |
|---|---|---|
| 1 | 1, 4, 5, 8, 10 | |
| 2 | 2, 3, 6, 7, 9 |
For example, has distances to and to , so it joins cluster 2. For Set 3, use its separate ten-point table. Exhaustive comparison of 45 pairs gives medoids and , with total Euclidean distance approximately . The assignments are and , respectively. For example, is distance 2 from and from , so it joins the second cluster.
5. Hierarchical clustering — ⭐ IMPORTANT
A hierarchy is shown as a dendrogram; merging height represents dissimilarity. Cut it at a height to obtain a chosen number of clusters.
- Agglomerative (bottom-up): each point starts as its own cluster. Repeatedly merge the closest clusters, update distances and continue to one cluster or the chosen stopping rule.
- Divisive (top-down): start with one cluster and split recursively. One method builds a minimum spanning tree and removes long edges to create components.
Linkage defines the distance between two clusters :
Centroid linkage compares means; Ward’s method merges the pair with the smallest increase in within-cluster SSE (usually with Euclidean geometry).
| Linkage | Strength | Limitation |
|---|---|---|
| Single / MIN | Can join irregular shapes | Chaining: noise bridges separate groups |
| Complete / MAX | Promotes compact groups | Can split elongated or large groups; sensitive to extreme separations |
| Average | Compromise between single and complete | Often favours compact clusters |
| Ward | Controls increase in SSE | Often favours compact/spherical clusters |
Example: points 1, 2, 5, 9, single linkage. Merge {1},{2} at distance 1, then {1,2},{5} at distance 3, then {1,2,5},{9} at distance 4. A cut between 3 and 4 gives {1,2,5}, {9}. Distances are recomputed by the chosen linkage after every merge. Basic algorithms may need storage and up to time; implementations can improve this. A merge in ordinary agglomerative clustering is not later undone.
2025 CO5(b) (3+7 marks): List out all hierarchical methods for clustering data. Define and explain any one hierarchical clustering methods.
2026 CO5(b) (3+7 marks): List out all hierarchical methods for clustering data. Use Agglomerative Clustering method for finding best possible clusters of the Ice Cream Sales data set.
The twelve-record dataset referenced by the 2026 question appears beside CO5(a) in the original image below.
The two principal hierarchical methods are agglomerative, which begins with one cluster per object and merges clusters, and divisive, which begins with one cluster and splits it. Agglomerative linkage choices include single, complete, average, centroid and Ward’s method.
The ice-cream dataset contains records 1:(18,120), 2:(20,150), 3:(22,165), 4:(34,320), 5:(40,400), 6:(26,210), 7:(28,240), 8:(32,300), 9:(24,180), 10:(36,350), 11:(30,260), 12:(38,370), where each pair is (temperature, sales).
The paper does not specify a distance, linkage, scaling or number of clusters. For one reproducible answer, use unscaled Euclidean distance, single linkage and a two-cluster cut. Under single linkage, the distance between clusters is the smallest distance between any point in one and any point in the other. Start with twelve individual clusters and merge the closest pair at each step.
| Merge distance, approximately | Merge or joining event |
|---|---|
| 15.13 | Merge 2 with 3; then join 9 to {2,3}. |
| 20.10 | Merge 7 with 11; merge 8 with 4; merge 10 with 12. |
| 30.07 | Join 1 to {2,3,9}; join 6 to that cluster and then join {7,11}; join {8,4} to {10,12}, then join 5. |
| 40.05 | The remaining two groups join through records 11 and 8. |
For example, . The final bridge is . Ties may be resolved in a different order without changing these two groups.
Cutting the dendrogram immediately before the last merge gives {1,2,3,6,7,9,11} and {4,5,8,10,12}. Other linkage, scaling or cut choices can give different clusters; the question does not uniquely define “best”.
2022 CO2 Q2(a)(iii): Explain the drawbacks of the divisive method.
2022 CO2 Q2(b): Construct a CF-tree for the given clusters; explain the challenges of high-dimensional clustering and their solutions; describe CLIQUE and its strengths and weaknesses.
Divisive clustering begins with all objects in one cluster and repeatedly splits a cluster. It can be computationally expensive because there are many possible splits; an early wrong split usually cannot be undone. The result depends on the splitting rule and stopping condition.
CF-tree: For each cluster calculate , where is the number of points, and , with sums coordinate-wise. The parent entry is . Reading the blue points from the figure gives the following coordinate-wise summaries:
| Cluster | |||
|---|---|---|---|
| 6 | (14, 19) | (40, 73) | |
| 6 | (44, 17) | (330, 55) | |
| 7 | (40, 61) | (236, 539) | |
| 19 | (98, 97) | (606, 667) |
For example, consists of . Add the cluster CFs component-wise to get the parent . A schematic root contains and points to entries . The precise node layout depends on the branching factor and threshold, which the question does not state.
High dimensionality: Distances can become less discriminating, data becomes sparse and the number of possible subspaces grows rapidly. Normalize relevant features, use feature selection or dimensionality reduction, or apply subspace clustering to find groups meaningful in subsets of dimensions.
CLIQUE: (1) Divide each dimension into equal-width intervals. (2) Find dense one-dimensional units using the density threshold. (3) Generate higher-dimensional candidate units from dense lower-dimensional units, retaining those that meet the threshold. (4) Join adjacent dense units into clusters and describe each cluster. It can discover clusters in different subspaces and uses downward closure to prune candidates. Its outcome depends on the grid and density threshold, and candidate subspaces can still grow rapidly.
6. DBSCAN: density-based clustering — ⭐ IMPORTANT
DBSCAN finds dense regions separated by sparse areas. Its parameters are neighbourhood radius and MinPts. Use the standard convention below: the neighbourhood includes the point itself, and a core point has at least MinPts points in it.
- .
- Core: .
- Border: not core, but within of a core point.
- Noise: neither core nor border.
- is directly density-reachable from core point when . Density reachability is a chain of such steps and is not generally symmetric for border points. Two points are density-connected if both are density-reachable from a common point.
Algorithm: visit an unvisited point; retrieve its neighbourhood. If it is core, start a cluster and expand through all connected core points, adding their border neighbours. Otherwise mark it noise provisionally; it may later be included as a border point. Repeat until all points are visited. Core-connected components are stable for fixed parameters, but a border point reachable from two clusters can be assigned according to processing order; the lecture’s blanket order-independence claim needs this qualification.
Small example: 1D points 0, 0.1, 0.2, 0.3, 1.0, , MinPts = 3 including self. 0.1 and 0.2 are core; 0 and 0.3 are border; 1.0 is noise. Cluster {0,0.1,0.2,0.3} forms via the two core points.
Choose parameters using domain knowledge and a sorted k-distance graph: a bend can suggest ; ensure the neighbour-count convention matches MinPts. Too small a radius/too high MinPts yields excess noise; too large a radius/too low MinPts merges clusters. DBSCAN discovers arbitrary shapes, does not require in advance and identifies noise, but struggles with varying densities, high dimensions and poorly chosen parameters.
2025 CO5(c) (2+8 marks): What is the drawback of k-means algorithm? Explain the DBSCAN clustering methods in detail.
2026 CO5(c) (2+8 marks): What is the drawback of k-means algorithm? Explain any density-based clustering algorithm in detail.
Drawbacks of k-means: The number of clusters must be chosen in advance. Results depend on initial centroids and attribute scales, and means are sensitive to outliers. The method can perform poorly for irregularly shaped clusters or clusters of very different densities or sizes.
DBSCAN (Density-Based Spatial Clustering of Applications with Noise) forms clusters from dense regions separated by sparse regions. It uses two parameters: neighbourhood radius and minimum number of points MinPts. In this answer, the neighbourhood includes the point itself.
- An -neighbourhood of point contains all points at distance at most from .
- A core point has at least
MinPtspoints in its neighbourhood. A border point is not core but lies within the neighbourhood of a core point. A noise point is neither core nor border. - Select an unvisited point and find its neighbourhood. If it is a core point, start a new cluster. Add its neighbours and continue expanding from each newly discovered core point. Border points are included but do not expand the cluster.
- If an unvisited point is not core, mark it as noise provisionally; it can later be added as a border point of a cluster. Continue until every point has been visited.
For example, let the points be 0, 0.1, 0.2, 0.3, 1.0, with and MinPts=3. Points 0.1 and 0.2 each have at least three neighbourhood points, including themselves, so they are core. Points 0 and 0.3 are border points. Point 1.0 is noise. DBSCAN returns cluster {0, 0.1, 0.2, 0.3} and leaves 1.0 as noise.
DBSCAN does not require , can find non-spherical clusters and identifies noise. Its limitations include difficulty with clusters of varying densities, high-dimensional data and choosing suitable parameter values.
7. Quick comparison — ⭐ IMPORTANT; PAM NOT PRESENT
| Method | Representative or structure | Need ? | Handles non-spherical clusters? | Outliers |
|---|---|---|---|---|
| k-means | Mean centroid | Yes | Often poorly | Can move mean strongly |
| PAM | Observed medoid | Yes | Depends on distance and assignment | More robust than mean |
| Hierarchical | Dendrogram and linkage | Cut chosen afterwards | Single linkage can | Depends on linkage; chaining possible |
| DBSCAN | Density-connected regions | No | Yes, when densities fit parameters | Explicitly marks noise |



















