5 Clustering Methods

Data Warehousing and Data Mining · Unit 5

Clustering Methods

Exam-focused notes for Clustering Methods (Data Warehousing and Data Mining, BIT454): what the TU syllabus asks and how it has actually been tested, with 5 solved past questions from this unit.

Clustering Methods in short

Clustering groups similar objects together without using class labels. It is used for customer segments, image grouping, and for finding patterns in unknown data.

Clustering Methods: notes

Clustering approaches and types

A good clustering has high similarity inside a cluster and low similarity between clusters. Main approaches:

  • Partitioning methods: divide $n$ objects into $k$ groups. Examples: k-means, k-medoids.
  • Hierarchical methods: build a tree of clusters (a dendrogram). They can be agglomerative or divisive.
  • Density-based methods: grow clusters while the neighborhood is dense enough. Example: DBSCAN. They find clusters of any shape.
  • Grid-based methods: divide space into cells and cluster the cells. Example: STING, CLIQUE. They are fast.
  • Model-based methods: fit a statistical model to the data. Example: Expectation-Maximization.

K-means algorithm and limitations

K-means is a partitioning method. Each cluster is represented by its centroid (the mean of its points).

Algorithm:

  • Choose $k$ and pick $k$ objects as initial centroids.
  • Assign every object to the nearest centroid.
  • Recompute each centroid as the mean of its cluster.
  • Repeat assign and recompute until the clusters do not change.

The aim is to minimize the sum of squared errors: $E = \sum_{i=1}^{k}\sum_{p \in C_i} |p - m_i|^2$.

Worked example. Data: 2, 4, 10, 12, 3, 20, 30, 11, 25 with $k = 2$ and initial centroids 2 and 12.

RoundCluster 1Cluster 2New centroids
12, 4, 310, 12, 20, 30, 11, 253 and 18
22, 4, 10, 312, 20, 30, 11, 254.75 and 19.6
32, 3, 4, 10, 11, 1220, 25, 307 and 25
42, 3, 4, 10, 11, 1220, 25, 307 and 25 (no change)

The clusters stopped changing in round 4, so the final clusters are {2, 3, 4, 10, 11, 12} and {20, 25, 30}.

Limitations:

  • The user must give $k$ in advance.
  • The result depends on the starting centroids and may be a local best only.
  • Outliers pull the mean and distort clusters.
  • It works poorly for clusters that are not round or have very different sizes.
  • It works only where a mean can be computed, so it is unsuitable for categorical data.

Using k-medoids (real objects as centers) reduces the effect of outliers.

What this unit covers

  • Clustering approaches and types
  • K-means algorithm and limitations
  • Agglomerative clustering approach
  • Divisive clustering approach
  • Types of data in clustering
  • High dimensional data clustering
  • Similarity measures for ordinal data

K-means algorithm and limitations

2081 · 10 marks

List different clustering approaches. Write the algorithm of K-means algorithm. What are its limitations?[10]

Show solved answer

Model Answer: Clustering Approaches and K-Means Algorithm

Different Clustering Approaches (3 marks)

Clustering approaches can be classified into the following main categories:

  1. Partitioning Methods

    • Divide data into k non-overlapping clusters
    • Examples: K-means, K-medoids, PAM (Partitioning Around Medoids)
  2. Hierarchical Methods

    • Build a hierarchy of clusters (dendrogram)
    • Agglomerative (bottom-up): Start with individual points, merge into clusters
    • Divisive (top-down): Start with one cluster, split into smaller clusters
  3. Density-Based Methods

    • Cluster based on density of data points
    • Examples: DBSCAN, OPTICS
    • Can find arbitrary-shaped clusters
  4. Grid-Based Methods

    • Divide data space into grid cells
    • Cluster based on grid structure
    • Example: STING
  5. Model-Based Methods

    • Assume data generated from probability distribution
    • Example: Gaussian Mixture Models (GMM)

K-Means Algorithm (5 marks)

Algorithm Steps:

Input: Dataset D with n objects, number of clusters k

Output: k clusters with minimum within-cluster variance

Steps:

  1. Initialize: Randomly select k initial cluster centers (centroids) from the dataset or randomly in the data space.

  2. Assignment Step: Assign each data point to the nearest centroid using Euclidean distance:

    For each point x_i in D:
        d = minimum distance to any centroid
        Assign x_i to cluster C_j where centroid is nearest
    
  3. Update Step: Recalculate centroids as the mean of all points in each cluster:

    For each cluster C_j:
        centroid_j = (1/|C_j|) * Σ(x_i) for all x_i in C_j
    
  4. Convergence Check: If centroids have not changed (or change is below threshold), stop. Otherwise, go to Step 2.

  5. Output: Final k clusters and their centroids.

Pseudocode:

Algorithm K-Means(D, k)
  C = randomly select k centroids from D
  repeat
    for each point x in D do
      assign x to nearest centroid
    end for
    for each cluster j do
      update centroid_j = mean of all points in cluster j
    end for
  until centroids do not change
  return clusters

Limitations of K-Means (2 marks)

  1. Sensitive to Initial Centroids: Different initial selections may lead to different final clusters. Algorithm may converge to local optima rather than global optimum.

  2. Fixed Number of Clusters: Must specify k in advance. No automatic method to determine optimal k.

  3. Assumes Spherical Clusters: Works best with roughly spherical, similarly-sized clusters. Fails with elongated or irregular cluster shapes.

  4. Sensitive to Outliers: Outliers can significantly affect centroid calculation and cluster quality.

  5. Computational Cost: For large datasets with many dimensions, distance calculations become expensive.

  6. Equal Cluster Size Assumption: Tends to produce clusters of roughly equal size, which may not reflect actual data distribution.

  7. Convergence Issues: May converge slowly or get stuck in local minima.

  8. Not Suitable for Categorical Data: K-means uses Euclidean distance, designed for numerical data only.

Open this answer on its own page →

Similarity measures for ordinal data

2082.1 · 5 marks

How do you find similarities between ordinal data attributes? Explain. [5]

Ordinal data are categorical attributes with a natural ordering or ranking among the categories. Examples include: education level (high school < bachelor < master < PhD), satisfaction ratings (poor < fair < good < excellent), or grades (A B C D F). Convert ordinal values to ranks and compute dis...

Open this answer on its own page →

Types of data in clustering

2082.1 · 5 marks

Explain the types of data in clustering. [5]

Since reference notes are not provided, this answer draws from standard clustering theory in computer science: - Consists of continuous or discrete numeric values - Examples: age, salary, temperature, distance measurements - Can be directly used in distance calculations (Euclidean, Manhattan dist...

Open this answer on its own page →

High dimensional data clustering

2082.1 · 5 marks

What is outlier? How do you cluster high dimensional data? [2+3]

(a) What is an Outlier? An outlier is a data point that deviates significantly from the normal pattern or distribution of the rest of the dataset. Key characteristics: - It is substantially different from other observations - It lies far away from the central tendency of the data - It may represe...

Open this answer on its own page →

Agglomerative clustering approach

2082.1 · 5 marks

Differentiate between agglomerative and divisive clustering approach. [5]

Agglomerative clustering is a bottom-up hierarchical clustering approach that works as follows: - Starts with each data point as an individual cluster - Iteratively merges the two closest/most similar clusters into a single cluster - Continues merging until all points belong to one cluster or a s...

Open this answer on its own page →