Problem K-Means solves poorly: You have customer data but don't know if you should segment into 3, 5, or 10 groups. K-Means forces you to guess K, then start over if wrong.
Hierarchical solution: Build the full tree ONCE, then examine it to choose the natural number of clusters. The tree shows you WHERE the big separations occur.
Large datasets (use K-Means, DBSCAN, or mini-batch variants)
Clusters with complex shapes (use DBSCAN instead)
Need to update clusters as new data arrives (hierarchical requires full rebuild)
Recall Explain to a 12-year-old
Imagine you have a bunch of LEGO bricks scattered on the floor, different colors and sizes. Hierarchical clustering is like organizing them into groups.
Aglomerative (bottom-up): You start by picking up each brick. Then you look for two bricks that are MOST similar (maybe both red, or both 2x4 size) and put them together. Then you keep doing this: find the two groups that are most similar and combine them. Maybe you combine two red piles, or a red pile with a pink pile (they're kinda similar!). Eventually, all your bricks are in one giant pile.
The cool part? You took a video the whole time. Now you can rewind and stop at ANY point to see different groupings. Maybe you want3 piles (primary colors), or 10 piles (every shade), or 100 piles (nearly every brick separate). You don't have to choose until you see the video!
Divisive (top-down): This is like doing it backwards. Start with all bricks in one pile, then split it into two groups (maybe "red-ish" vs "blue-ish"). Then split each of those groups again, and again, until every brick is alone.
The "dendrogram" is like a family tree of your LEGO bricks, showing which bricks are "related" (similar) and which are "distant cousins" (very different). The height of each branch shows HOW different the groups were when you combined them.
Dendrogram Visualization — tree representation of cluster hierarchy
Elbow Method — used to determine optimal K; applied to dendrogram merge heights
Single-Link vs Complete-Link — trade-off between sensitivity to chaining vs outliers
Time Complexity Analysis — O(n3) naive, O(n2logn) optimized vs K-Means O(nkd)
Gredy Algorithms — hierarchical uses gredy merging, not globally optimal
Within-Cluster Sum of Squares — Ward's method minimizes WCSS increase
#flashcards/ai-ml
What are the two main types of hierarchical clustering? :: Agglomerative (bottom-up merging) and Divisive (top-down splitting)
What is the output of hierarchical clustering?
A dendrogram (tree structure) showing cluster relationships at all levels of granularity, not just a single partition
What is the time complexity of aglomerative clustering with a priority queue?
O(n2logn) time and O(n2) space for the distance matrix
What is single linkage criterion?
Distance between clusters = minimum distance between any two points from the two clusters: minxi∈Cp,xj∈Cqd(xi,xj)
What is complete linkage criterion?
Distance between clusters = maximum distance between any two points from the two clusters: maxxi∈Cp,xj∈Cqd(xi,xj)
What is Ward's linkage criterion?
Merges clusters that minimize the increase in total within-cluster variance: ∣Cp∣+∣Cq∣∣Cp∣∣Cq∣∣μp−μq∣∣2
What is the chaining effect in single linkage?
Single linkage connects clusters through outlier bridges or noise points, creating elongated chains instead of compact clusters
How do you choose the number of clusters from a dendrogram?
Look for large vertical gaps (big jumps in merge height) and cut the dendrogram horizontally just before a large jump
What is the main advantage of hierarchical clustering over K-Means?
No need to specify K upfront — you get cluster structure at all granularities and can choose K by examining the dendrogram
Why is hierarchical clustering not globally optimal?
It uses gredy local decisions at each merge step. Once two clusters are merged, they never split, so early mistakes propagate
When should you use complete linkage over single linkage?
Use complete linkage when you want compact, well-separated clusters and your data has noise or outliers. Single linkage sufers from chaining in these cases
What is the main disadvantage of hierarchical clustering for large datasets?
O(n2) space for distance matrix and O(n2logn) time makes it impractical for n>10,000 points
What does the height of a merge in a dendrogram represent?
The distance or dissimilarity between the two clusters being merged at that step
How does average linkage differ from single and complete linkage?
Average linkage uses the mean of all pairwise distances between clusters, providing a compromise between single (minimum) and complete (maximum)
Why is Ward's method good for creating balanced clusters?
It minimizes within-cluster variance increase, which naturally produces compact clusters of similar size and low internal variance
Hierarchical clustering ek bahut powerful technique hai jisme hum data points ko tree structure mein organize karte hain. Socho jaise family tree hota hai — sabse niche individual log, phir chhote families, phir bade families, aur top peura extended family. Isi tarah, hierarchical clustering mein hum data points ko gradually merge ya split karte hain.
Do main approaches hain: Agglomerative (bottom-up) aur Divisive (top-down). Agglomerative mein hum har point ko alag cluster consider karte hain, phir sabse similar clusters ko merge karte jate hain jab tak sab ek cluster mein na aa jaayein. Divisive mein ulta — sabhi points ek cluster mein start karte hain, phir split karte karte individual points tak pahunchte hain. Agglomerative zyada common hai kyunki computationally efficient hai.
Sabse interesting part hai linkage criterion — yeh decide karta hai ki do clusters ke bech distance kaise measure karein. Single linkage (nearest points), complete linkage (farthest points), average linkage (sabka average), aur Ward's method (variance minimize karo) — harek different shape ke clusters banata hai. Output ek