ArticleslgStudy

computer science

Hierarchical clustering

Hierarchical clustering is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Hierarchical clustering rather than just read about it. In short: In data mining and statistics, hierarchical clustering (also called hierarchical cluster analysis or HCA) is a method of cluster analysis that seeks to build a hierarchy of clusters. Strategies for hierarchical clustering generally fall into two categories: Agglomerative: Agglomerative clustering, often referred to as a "bottom-up" approach, begins with each data point as an individual cluster.

Hierarchical clustering — main illustration
Hierarchical clustering — illustration

Key takeaways

  • Hierarchical clustering belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Hierarchical clustering to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Hierarchical clustering from memory before moving on to harder problems.

Reference excerpt

In data mining and statistics, hierarchical clustering (also called hierarchical cluster analysis or HCA) is a method of cluster analysis that seeks to build a hierarchy of clusters. Strategies for hierarchical clustering generally fall into two categories:

Agglomerative: Agglomerative clustering, often referred to as a "bottom-up" approach, begins with each data point as an individual cluster. At each step, the algorithm merges the two most similar clusters based on a chosen distance metric (e.g., Euclidean distance) and linkage criterion (e.g., single-linkage, complete-linkage). This process continues until all data points are combined into a single cluster or a stopping criterion is met. Agglomerative methods are more commonly used due to their simplicity and computational efficiency for small to medium-sized datasets. Divisive: Divisive clustering, known as a "top-down" approach, starts with all data points in a single cluster and recursively splits the cluster into smaller ones. At each step, the algorithm selects a cluster and divides it into two or more subsets, often using a criterion such as maximizing the distance between resulting clusters. Divisive methods are less common but can be useful when the goal is to identify large, distinct clusters first. In general, the merges and splits are determined in a greedy manner. The results of hierarchical clustering are usually presented in a dendrogram. Hierarchical clustering has the distinct advantage that any valid measure of distance can be used. In fact, the observations themselves are not required: all that is used is a matrix of distances. On the other hand, except for the special case of single-linkage distance, none of the algorithms (except exhaustive search in O ( 2 n ) {\displaystyle {\mathcal {O}}(2^{n})} ) can be guaranteed to find the optimum solution.

Complexity The standard algorithm for hierarchical agglomerative clustering (HAC) has a time complexity of O ( n 3 ) {\displaystyle {\mathcal {O}}(n^{3})} and requires Ω ( n 2 ) {\displaystyle \Omega (n^{2})} memory, which makes it too slow for even medium data sets. However, for some special cases, optimal efficient agglomerative methods (of complexity O ( n 2 ) {\displaystyle {\mathcal {O}}(n^{2})} ) are known: SLINK for single-linkage and CLINK for complete-linkage clustering. With a heap, the runtime of the general case can be reduced to O ( n 2 log ⁡ n ) {\displaystyle {\mathcal {O}}(n^{2}\log n)} instead of O ( n 3 ) {\displaystyle {\mathcal {O}}(n^{3})} , at the cost of additional the memory requirements. In many cases, the memory overheads of this approach are too large to make it practically usable. Methods exist which use quadtrees that demonstrate O ( n 2 ) {\displaystyle {\mathcal {O}}(n^{2})} total running time with O ( n ) {\displaystyle {\mathcal {O}}(n)} space. Divisive clustering with an exhaustive search is O ( 2 n ) {\displaystyle {\mathcal {O}}(2^{n})} , but it is common to use faster heuristics to choose splits, such as k-means.

Distance metrics While the linkage criterion determines how dissimilarity between sets of observations is computed, the underlying distance metric determines how dissimilarity between individual observations is measured. Because hierarchical clustering permits any valid measure of distance, the choice of metric is guided by the nature of the data and can have a significant effect on the resulting clustering. Euclidean distance is the most widely used metric for continuous numerical data. It corresponds to the straight-line distance between two points in Euclidean space and is the default choice in most statistical software:

d ( x , y ) = ∑ i = 1 n ( x i − y i ) 2 {\displaystyle d(\mathbf {x} ,\mathbf {y} )={\sqrt {\sum _{i=1}^{n}(x_{i}-y_{i})^{2}}}}

Manhattan distance (also called city-block or L1 distance) sums the absolute differences across features:

d ( x , y ) = ∑ i = 1 n | x i − y i | {\displaystyle d(\mathbf {x} ,\mathbf {y} )=\sum _{i=1}^{n}|x_{i}-y_{i}|}

… excerpt ends here. Continue reading the full article.

Illustrations

Hierarchical clustering: Raw data
Raw data
Hierarchical clustering: Traditional representation
Traditional representation
Hierarchical clustering: Animated illustration of agglomerative hierarchical clustering. Data points are progressively merged based on minimum distance, while the corresponding dendrogram is constructed simultaneously. Branch heights represent normalized distances between clusters.
Animated illustration of agglomerative hierarchical clustering. Data points are progressively merged based on minimum distance, while the corresponding dendrogram is constructed simultaneously. Branch heights represent normalized distances between clusters.
Hierarchical clustering: Hierarchical clustering dendrogram of the Iris dataset (using R). Source
Hierarchical clustering dendrogram of the Iris dataset (using R). Source
Hierarchical clustering: Hierarchical clustering and interactive dendrogram visualization in Orange data mining suite.
Hierarchical clustering and interactive dendrogram visualization in Orange data mining suite.

Worked examples

Example 1 — a first encounter with Hierarchical clustering

Start with the simplest possible case. Write down what Hierarchical clustering claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Hierarchical clustering before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Hierarchical clustering ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Hierarchical clustering

In research
Hierarchical clustering appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Hierarchical clustering in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Hierarchical clustering is common in secondary-school and first-year university syllabi. It links to neighbouring topics Cluster analysis algorithms, Network analysis, so understanding it makes those chapters shorter.
In everyday life
Look for Hierarchical clustering outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Hierarchical clustering” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Hierarchical clustering in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Hierarchical clustering means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Hierarchical clustering out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Hierarchical clustering in simple terms?

In data mining and statistics, hierarchical clustering (also called hierarchical cluster analysis or HCA) is a method of cluster analysis that seeks to build a hierarchy of clusters. Strategies for hierarchical clustering generally fall into two categories: Agglomerative: Agglomerative clustering…

Why does Hierarchical clustering matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Hierarchical clustering?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Hierarchical clustering.

Tags

  • Cluster analysis algorithms
  • Network analysis

Keep exploring