Hierarchical Clustering: Practical Guide for Data-Driven Decisions
By MCP Analytics Team | Published , updated
Hierarchical clustering groups similar cases step by step into a tree, called a dendrogram, and you cut the tree at the height that gives the number of clusters you want.
You're staring at a spreadsheet with 5,000 customers. Each row holds purchase history, engagement metrics, demographic data. You know valuable segments exist in this data (high-value loyalists, at-risk churners, bargain hunters) but k-means keeps asking you the question you can't answer: "How many clusters do you want?" You guess three. Then five. Then seven. Each time, you rerun the algorithm, wondering if you're missing the natural structure hiding in your data. There's a better way.
Hierarchical clustering does not ask you to pick a cluster count up front. It builds a complete tree of relationships showing how every customer connects to every other customer, revealing patterns at every level of granularity. A dendrogram shows the merges for the chosen features and distance rule. It can help compare cuts, but the tree does not pick a best cut for you.
But the real power isn't just avoiding guesswork. Hierarchical clustering automates the discovery of nested segments you'd never think to look for: within your "high-value" segment, there's a subsegment of recent converts who behave differently from long-time loyalists. Within "at-risk" customers, there's a group that responds to discounts and another that needs product education. These nested patterns drive automation opportunities, targeted campaigns that adapt based on which layer of the hierarchy each customer occupies.
Worked Example (Simulated): Can Spend and Visit Scores Show Groups?
Question. Can spend and visit scores show clear groups in made-up data?
Inputs. Simulated data, seed 17. 24 rows with two scores, spend_index and visits_index, built from three groups of 8 rows with built-in centres (2, 8), (8, 2) and (7, 8) and spread 0.55. Each score is then scaled to its own mean and spread.
Method. Euclidean distance and Ward linkage, then the tree is cut into 3 groups.
import numpy as np
from scipy.cluster.hierarchy import linkage, fcluster
SEED = 17
rng = np.random.default_rng(SEED)
centers = np.array([[2.0, 8.0], [8.0, 2.0], [7.0, 8.0]])
labels = ["low_spend_high_visits", "high_spend_low_visits",
"high_spend_high_visits"]
rows = []
for label, center in zip(labels, centers):
values = rng.normal(loc=center, scale=0.55, size=(8, 2))
rows.extend((label, *row) for row in values)
names = np.array([row[0] for row in rows])
X = np.array([row[1:] for row in rows])
Z = (X - X.mean(axis=0)) / X.std(axis=0, ddof=0)
links = linkage(Z, method="ward", metric="euclidean")
cluster = fcluster(links, t=3, criterion="maxclust")
print(f"Simulated data, seed {SEED}")
print(f"Rows: {len(X)}; features: spend_index, visits_index")
print("Preprocessing: z-score each feature (population standard deviation)")
print("Method: Euclidean distance; Ward linkage; cut tree into 3 clusters")
for c in sorted(set(cluster)):
m = X[cluster == c]
print(f"Cluster {c}: n={len(m)}, mean spend_index={m[:, 0].mean():.2f}, "
f"mean visits_index={m[:, 1].mean():.2f}")
matched = sum(max(np.sum(cluster[names == lab] == c) for c in set(cluster))
for lab in labels)
print(f"Rows grouped with their generated source group: {matched}/{len(X)}")
Printed output:
Simulated data, seed 17
Rows: 24; features: spend_index, visits_index
Preprocessing: z-score each feature (population standard deviation)
Method: Euclidean distance; Ward linkage; cut tree into 3 clusters
Cluster 1: n=8, mean spend_index=7.78, mean visits_index=2.06
Cluster 2: n=8, mean spend_index=6.96, mean visits_index=7.75
Cluster 3: n=8, mean spend_index=1.58, mean visits_index=8.03
Rows grouped with their generated source group: 24/24
Result. Each of the three groups has 8 rows. Cluster 1 has mean spend 7.78 and visits 2.06 (high spend, few visits). Cluster 2 has spend 6.96 and visits 7.75 (high spend, many visits). Cluster 3 has spend 1.58 and visits 8.03 (low spend, many visits). These means are close to the built-in centres, and all 24 rows were grouped with their generated source group. A shop could review whether such groups call for different offers; the clustering alone cannot answer that.
Limit. The data was built to have clear groups, and this is one simulated run. It does not show how well the method works on real customer records.
Sources
- scikit-learn developers. scikit-learn: clustering. https://scikit-learn.org/stable/modules/clustering.html. Covers: implementation documentation.
Why Hierarchical Clustering Reveals Structure Other Methods Miss
Most clustering algorithms produce flat partitions. K-means divides customers into exactly k groups. DBSCAN finds density-based clusters. These are final answers. You get your segments and move forward. Hierarchical clustering operates differently: it builds one tree of nested segmentations, and each cut of the tree gives a different set of segments to compare.
The algorithm builds a tree where each leaf represents an individual customer and each branch point represents a merge decision. At the bottom, you have 5,000 clusters (one per customer). At the top, you have one cluster (everyone). In between, you have the nested groupings the merges produce, one level for each merge. This structure reveals relationships that flat clustering obscures.
Imagine a retail dataset with three behavioral segments (a hypothetical illustration):
- Discount shoppers: Purchase only during sales
- Premium buyers: Purchase full-price items frequently
- Hybrid customers: Mix of both behaviors
K-means with k=3 might identify these groups. But hierarchical clustering shows you something deeper: the hybrid segment is actually closer to premium buyers (they share high lifetime value) than to discount shoppers. When you need to allocate a limited marketing budget, this relationship matters. You'd group hybrids with premium customers for high-value retention campaigns, not lump them with discount-seeking bargain hunters.
This structural understanding creates automation opportunities. Instead of manually deciding which campaign fits which segment, you can automate workflows based on dendrogram position. One possible rule is to test messaging with customers near branch points (sitting between two segments) and to run more targeted campaigns for customers deep within clusters that stay stable across cuts. Treat this as a hypothesis to check against cluster stability and campaign results. The tree structure itself becomes your decision logic.
Agglomerative vs. Divisive: The Bottom-Up and Top-Down Battle
Hierarchical clustering comes in two flavors: agglomerative (bottom-up) and divisive (top-down). Agglomerative clustering builds groups from individual rows. Divisive clustering starts with one group and splits it.
Agglomerative Clustering: Building from Individual to Group
Agglomerative clustering starts with each customer as their own cluster, then repeatedly merges the two most similar clusters until everything belongs to one giant cluster. This creates a tree from the bottom up.
The algorithm is straightforward:
- Start with n clusters (one per observation)
- Calculate pairwise distances between all clusters
- Merge the two closest clusters
- Repeat steps 2-3 until one cluster remains
Each merge happens at a specific distance value, which the dendrogram captures as height. Large jumps in height signal meaningful divisions. The algorithm had to merge very dissimilar clusters because all similar ones were already combined.
Here's what this looks like with a small customer dataset:
Initial: [A] [B] [C] [D] [E]
Step 1: Merge A and B (distance: 2.1)
[AB] [C] [D] [E]
Step 2: Merge D and E (distance: 2.3)
[AB] [C] [DE]
Step 3: Merge AB and C (distance: 5.7)
[ABC] [DE]
Step 4: Merge ABC and DE (distance: 12.4)
[ABCDE]
Notice the jump from 5.7 to 12.4. That large gap suggests two natural clusters: {A, B, C} and {D, E}. Behind this pattern might be two distinct customer groups: perhaps ABC represents customers who purchase frequently with low average order value, while DE represents infrequent purchasers with high order value.
Divisive Clustering: Splitting from Group to Individual
Divisive clustering works in reverse. Start with everyone in one cluster, then recursively split into smaller groups until each customer stands alone. This top-down approach identifies major divisions first.
In theory, divisive clustering sounds appealing: find the biggest behavioral difference in your customer base, split there, then refine within each group. In practice, it is computationally expensive (there are 2^(n-1) - 1 ways to split n observations into two groups), so implementations use heuristics, and it is used less often than agglomerative.
Use divisive clustering only when:
- You have strong domain knowledge suggesting a clear top-level split (B2B vs. B2C customers, geographic regions, product categories)
- You're working with massive datasets where identifying major divisions first reduces computational burden
- Your data has a natural hierarchical structure you want to preserve (organizational charts, product taxonomies)
For customer segmentation, behavioral analysis, and marketing automation, agglomerative clustering is the usual starting point. It is available in most analytics tools, but it compares customers pair by pair, so run time and memory grow quickly on large tables. Check the result on your own data before relying on it.
Linkage Methods: The Four Choices That Change Everything
Once you've chosen agglomerative clustering, you face another decision: how do you measure distance between clusters? When cluster A contains customers {1, 2, 3} and cluster B contains customers {4, 5}, what distance do you use to decide whether to merge them?
This is the linkage method, and it fundamentally shapes your results. The four main approaches each solve for different segment characteristics.
Ward's Linkage: Minimizing Within-Cluster Variance
Ward's method merges clusters to minimize the total within-cluster variance. At each step, it considers all possible merges and chooses the one that increases total variance the least. This favors compact clusters, where members are close to each other. It does not guarantee balanced sizes, so check how many customers land in each cluster.
Ward's linkage is one option when you want each merge to limit the rise in within-group variance. Check if its groups fit your data and business goal.
For a made-up e-commerce dataset, a Ward's dendrogram might give groups like these (all numbers made up):
- Cluster 1 (n=1,247): High frequency, low AOV, responds to email campaigns
- Cluster 2 (n=892): Low frequency, high AOV, discovers products via organic search
- Cluster 3 (n=2,116): Medium frequency, medium AOV, driven by retargeting ads
- Cluster 4 (n=745): Very high frequency, high AOV, brand loyalists
Ward's linkage aims for compact groups, but check on your data whether the groups are different enough to act on.
Complete Linkage: Maximum Distance Between Points
Complete linkage (also called "farthest neighbor") defines cluster distance as the maximum distance between any two points in different clusters. It won't merge two clusters unless even their most distant members are relatively close.
This produces tight, compact clusters with low internal variance. Use complete linkage when you want segments with very strict boundaries: customers in cluster A are definitively not like customers in cluster B.
The tradeoff: complete linkage can create very small clusters for outliers. A few unusual customers form their own tiny segments instead of being absorbed into larger groups. In customer segmentation, this might be exactly what you want (identify your most unusual high-value customers) or an annoyance (too many micro-segments to act on).
Average Linkage: Mean Distance Between All Point Pairs
Average linkage calculates the mean distance between all pairs of points in two clusters. It's a middle ground between complete (maximum distance) and single (minimum distance) linkage.
Use average linkage when your clusters have irregular shapes or varying densities. It's more robust to outliers than complete linkage and less prone to chaining than single linkage. For behavioral customer data with natural variation, purchase patterns that don't form perfect spherical clusters, average linkage often performs well.
Single Linkage: Minimum Distance Between Points
Single linkage (or "nearest neighbor") merges clusters based on the minimum distance between any two points. If even one customer in cluster A is close to one customer in cluster B, the clusters merge.
This creates elongated, chained clusters. In most customer segmentation scenarios, this is undesirable. You end up with segments where customers at opposite ends have little in common. They're connected through intermediaries, not through shared characteristics.
The only time single linkage shines: when you're explicitly looking for gradients or continua in customer behavior. Mapping a journey from "new customer" through "engaged user" to "brand advocate" might reveal meaningful transition points when customers are naturally connected in a chain-like structure.
Reading Dendrograms: The Visual Language of Customer Structure
The dendrogram is where hierarchical clustering becomes intuitive. This tree diagram encodes every merge decision as a visual relationship, transforming abstract mathematics into pattern recognition.
Each leaf at the bottom represents an individual customer. Moving up the tree, branches merge at different heights. The height of a merge indicates the distance (or dissimilarity) at which those clusters combined. Low merges represent very similar customers grouping together. High merges represent dissimilar groups being forced together because nothing else remains.
The largest vertical gaps in your dendrogram reveal natural divisions. Here's how to read them:
Finding the Optimal Number of Clusters
Draw a horizontal line across your dendrogram at different heights. Each height corresponds to a different number of clusters: the number of vertical lines your horizontal line crosses.
One common approach is to look for a large gap where no merges occur. Draw your horizontal line there. This represents the level where the next merge would force together very dissimilar groups, a boundary you may want to preserve. It is a guide, not a rule.
For example, imagine a dendrogram where:
- Clusters merge at heights: 1.2, 1.5, 1.8, 2.1, 2.4, 8.7, 9.2
Notice the jump from 2.4 to 8.7? That's your signal. Draw the line between those values, say, at height 5.0. This cuts the dendrogram into the number of clusters that existed before that large merge.
Behind this pattern is a story about your customers. Perhaps those first five merges at low heights represent individual differences within coherent segments (high-value customers with slightly different purchase frequencies). The jump to 8.7 represents combining fundamentally different behavioral groups (merging high-value and low-value segments), which you want to avoid.
Identifying Nested Segments for Automated Workflows
Dendrograms reveal structure at multiple levels simultaneously. You might have three primary segments at the top level, but within your "medium-value" segment, the dendrogram shows two clear subsegments that behave differently.
This nested structure creates automation opportunities:
- Level 1 (3 clusters): High-value, medium-value, low-value → Determines overall resource allocation
- Level 2 (7 clusters): Medium-value splits into "growing" and "stable" → Triggers different retention campaigns
- Level 3 (12 clusters): "Growing" splits into "discount-driven" and "product-driven" → Determines messaging and offer type
Your marketing automation can operate at all three levels simultaneously. New customers enter at Level 1 (resource allocation), then algorithms route them through Level 2 (campaign type) and Level 3 (specific messaging) based on their dendrogram position. The hierarchical structure becomes your decision tree.
Distance Metrics: Measuring Customer Similarity
Before hierarchical clustering can merge customers, it needs to measure how similar they are. The distance metric you choose determines which customers cluster together.
For customer behavioral data, you're typically working with mixed-type features: continuous variables (purchase frequency, average order value, days since last purchase) and categorical variables (preferred product category, acquisition channel, geographic region). Your distance metric must handle both.
Euclidean Distance: The Default for Continuous Features
Euclidean distance is the straight-line distance between two points in multidimensional space. For customers A and B with features (purchase_frequency, avg_order_value):
distance = sqrt((A_frequency - B_frequency)² + (A_aov - B_aov)²)
This works well when:
- All features are continuous and measured on similar scales
- You've standardized your variables (mean=0, standard deviation=1)
- The relationships between features are roughly linear
The critical requirement: standardization. If purchase frequency ranges from 1-50 and average order value ranges from $20-$2,000, the AOV dominates the distance calculation. Always standardize before using Euclidean distance.
Manhattan Distance: When Features Represent Different Dimensions
Manhattan distance (also called "city block" or L1 distance) sums the absolute differences across all dimensions:
distance = |A_frequency - B_frequency| + |A_aov - B_aov|
Use Manhattan distance when features represent fundamentally different things that shouldn't be combined into diagonal distances. In customer data, this often applies when you're clustering on independent behavioral metrics (email engagement + purchase behavior + support ticket history).
Gower Distance: The Solution for Mixed-Type Data
Most customer datasets mix continuous and categorical features. Gower distance handles this elegantly by computing component-wise distances and averaging:
- For continuous features: scaled absolute difference
- For categorical features: 0 if same, 1 if different
- For binary features: can weight matches/mismatches differently
This produces a distance matrix where every element ranges from 0 (identical customers) to 1 (completely different customers), regardless of your original feature types.
Use Gower distance when you're clustering on features like:
- Purchase frequency (continuous), preferred category (categorical), is_subscriber (binary)
- Days since last visit (continuous), device type (categorical), has_reviewed (binary)
From Dendrogram to Action: Cutting Clusters That Drive Business Decisions
You've built your dendrogram. You've identified the large vertical gaps that signal natural divisions. Now comes the translation work: turning hierarchical structure into operational customer segments.
This is where human judgment matters most. These aren't just clusters. They're groups of customers with shared needs, behaviors, and pain points. The dendrogram shows you the statistical structure. Your job is to understand the human story behind each branch.
Validate Clusters Against Business Logic
Statistical optimality doesn't guarantee business utility. After cutting your dendrogram at the chosen height, examine the resulting segments:
For each cluster, ask:
- What behavioral patterns define this group?
- What are these customers trying to accomplish?
- What needs do they share?
- How would I describe this segment to a marketing manager?
- What actions would I take differently for this group vs. others?
If you can't answer these questions clearly, your clusters might be statistically valid but operationally useless. Consider cutting at a different height or revisiting your feature selection.
Profile Each Segment with Summary Statistics
Once you've identified meaningful clusters, profile them to understand what makes each group unique. Calculate segment-level averages for your key metrics, such as purchase frequency, order value, lifetime value and churn risk. A made-up set of segments could look like this:
- High-Value Loyalists: frequent buyers with high order values and a low risk of leaving
- Growing Enthusiasts: moderate frequency and order value
- Discount Seekers: low order value, buying mostly on promotion
- At-Risk Former Buyers: rarely buy now and may be leaving
These segment names are made-up examples; a real profile table would come from your own data.
Profiling like this can show why groups differ. Segments that differ in frequency, order value and churn risk may call for different retention strategies, which you can test.
Map Segments to Automated Interventions
The power of hierarchical clustering for automation lies in its stability. Unlike k-means, which can assign the same customer to different clusters when you rerun the algorithm, hierarchical clustering produces deterministic results. This reliability enables automated workflows.
Build decision rules based on dendrogram position:
IF customer in "High-Value Loyalists" THEN
- Assign to VIP support queue
- Offer early access to new products
- Send quarterly relationship check-ins
IF customer in "Growing Enthusiasts" THEN
- Monitor for milestone purchases (5th, 10th order)
- Trigger education campaigns (product guides)
- Test incentives for frequency increase
IF customer in "Discount Seekers" THEN
- Limit discount exposure (avoid training)
- Test value-based messaging
- Monitor for signs of full-price purchase
IF customer in "At-Risk Former Buyers" THEN
- Launch win-back campaign (30-day sequence)
- Offer feedback survey + incentive
- Tag for manual outreach if high historical value
These rules run automatically as customers move through your system. New customers get clustered based on early behavior, then routed to appropriate workflows. The dendrogram's hierarchical structure even allows for graceful handling of edge cases: customers near cluster boundaries can receive blended messaging or enter A/B tests to determine best fit.
Scaling Hierarchical Clustering: When Size Becomes a Problem
Hierarchical clustering has a computational weakness: it requires storing all pairwise distances in memory. For n customers, that's n² distance calculations and O(n²) memory consumption. Around 10,000 observations, this becomes prohibitively expensive on standard hardware.
Most customer segmentation projects fall comfortably within this limit. Segment your active customers from the last 12 months, and you're often looking at 2,000-8,000 observations, perfectly manageable. But when you need to cluster larger datasets, you have several approaches.
Approach 1: Stratified Sampling for Representative Clustering
Instead of clustering all customers, cluster a representative sample:
- Draw a stratified random sample of 5,000-8,000 customers (stratify by key variables like customer tenure or total purchase value to ensure representativeness)
- Perform hierarchical clustering on the sample
- Calculate cluster centroids (the average feature values for each segment)
- Assign remaining customers to the nearest centroid using simple distance calculations
This approach trades off some precision for lower computation. The key insight: hierarchical clustering identifies the structure and segment definitions, then you use cheap distance-to-centroid calculations to classify everyone else.
Approach 2: Hybrid Clustering with BIRCH
BIRCH (Balanced Iterative Reducing and Clustering using Hierarchies) is designed for large datasets. It pre-processes data into a compact summary structure called a CF-tree (Clustering Feature tree), then applies hierarchical clustering to the summarized data rather than the raw observations.
Use BIRCH when:
- You have 50,000+ customers to cluster
- Your data contains many near-duplicate observations
- You need approximate clustering results quickly
The tradeoff: BIRCH makes assumptions about cluster shape (works best with spherical clusters) and requires tuning parameters that affect the CF-tree construction. For customer segmentation with well-separated behavioral groups, it works well.
Approach 3: Recursive Divisive Clustering
Manually implement a divisive approach:
- Use k-means to split your full dataset into 5-10 large groups
- Apply hierarchical clustering within each group separately
- Combine the results into a single hierarchical structure
This gives you the interpretability of hierarchical clustering (dendrograms for each subgroup) while avoiding the computational explosion of clustering 100,000+ observations simultaneously.
Feature Engineering: The Upstream Decision That Determines Everything
Hierarchical clustering operates on the features you provide. Garbage in, garbage out. The algorithm will dutifully cluster customers based on whatever variables you include, whether those variables actually matter for business decisions or not.
This is where understanding your customers as humans, not just data points, becomes critical. What behaviors actually signal different needs, different value, different churn risk? Those are your clustering features.
RFM Features: The Foundation of Behavioral Clustering
For transactional businesses, start with RFM (Recency, Frequency, Monetary value):
- Recency: Days since last purchase
- Frequency: Number of purchases in the past year
- Monetary value: Total spend in the past year
These three features capture the most fundamental dimensions of customer value. Hierarchical clustering on RFM alone often produces highly actionable segments because these variables directly map to customer lifecycle stage and profitability.
Engagement Features: Beyond Transactions
Many valuable customers don't purchase frequently but engage in other meaningful ways. Extend RFM with engagement metrics:
- Email open rate (past 90 days)
- Website visit frequency
- Content downloads or resource usage
- Social media interactions
- Support ticket volume
These features reveal customers who are building relationships with your brand even if purchase frequency is low. For B2B businesses with long sales cycles, engagement features may add information that transactions alone miss.
Product Preference Features: Understanding the "What"
Behavioral features (RFM, engagement) tell you how customers interact with your business. Product preference features tell you what they're seeking:
- Primary product category (encode categorically or use Gower distance)
- Product diversity (number of distinct categories purchased)
- Price point preference (average item price, not total spend)
- Seasonal purchase pattern (concentration in specific months)
Combining behavioral and preference features produces nuanced segments. You might discover that high-frequency, low-AOV customers split into two groups: one concentrated in a single product category (hobbyists or enthusiasts) and another purchasing across many categories (habitual browsers). These groups need different messaging even though their RFM profiles look similar.
Feature Scaling: The Non-Negotiable Preprocessing Step
Before clustering, standardize all continuous features to have mean=0 and standard deviation=1. This ensures no single variable dominates the distance calculation due to scale alone.
Original data:
Customer A: frequency=5, avg_order_value=$150, days_since=10
Customer B: frequency=8, avg_order_value=$155, days_since=45
After standardization (example):
Customer A: frequency=-0.42, avg_order_value=-0.08, days_since=-1.15
Customer B: frequency=0.73, avg_order_value=0.11, days_since=0.89
Now all features contribute proportionally to distance calculations, and your dendrogram reflects actual behavioral differences rather than measurement scale artifacts.
Common Pitfalls and How to Avoid Them
Hierarchical clustering is powerful but not foolproof. These are the mistakes that derail customer segmentation projects.
Pitfall 1: Forgetting to Standardize Features
You cluster on {purchase_frequency, average_order_value, days_since_last_purchase} without standardization. AOV ranges from $20-$2,000 while frequency ranges from 1-50. The algorithm sees two customers with identical frequency and days_since but $100 difference in AOV as extremely dissimilar: more dissimilar than two customers with identical AOV but massive frequency differences.
Solution: Always standardize continuous features before clustering. No exceptions.
Pitfall 2: Cutting Clusters at an Arbitrary Number
You decide in advance that you want exactly five segments because your CRM can handle five automated workflows. You cut the dendrogram at height=5.0 to get five clusters, ignoring the fact that the natural divisions occur at three clusters and seven clusters, not five.
Solution: Let the dendrogram guide your cluster count. If you need exactly five segments for operational reasons, at least understand what structure you're violating, and consider whether you can adapt your operations to respect the natural divisions.
Pitfall 3: Including Too Many Correlated Features
You include both "total_purchases_12mo" and "avg_purchases_per_month" (which is just total/12). You include "total_revenue" and "average_order_value" and "purchase_frequency" (where total = AOV × frequency). These redundant features weight certain aspects of behavior multiple times.
Solution: Choose orthogonal features that capture different dimensions of customer behavior. If features correlate at r > 0.7, pick one or use PCA to create uncorrelated components.
Pitfall 4: Clustering on Features You Can't Act On
You include demographic features like age and gender in your clustering. The dendrogram dutifully produces age-based segments. But your business can't tailor messaging by age. You're a regulated industry or you simply don't have age-specific content. The segments are statistically valid but operationally useless.
Solution: Cluster on features that connect to actions you can take. If you can't do anything differently for a customer based on feature X, don't include feature X in clustering. These segments tell you something important about customer needs, and you can act on those needs.
Comparing Hierarchical Clustering to Alternative Approaches
Hierarchical clustering isn't always the right choice. Understanding when to use alternatives clarifies when hierarchical methods shine.
Hierarchical vs. K-Means: Trading Automation for Speed
K-means is faster and scales to larger datasets. But it requires specifying k upfront, and it assumes spherical clusters of roughly equal size. Use k-means when:
- You have more than 10,000 observations and need fast results
- Your clusters are roughly spherical and similar in size
- You have strong prior knowledge about the right number of segments
Use hierarchical clustering when:
- You don't know how many segments exist
- You want to explore nested substructure within major segments
- You need stable, deterministic results for automation
- Understanding cluster relationships matters for strategy
Hierarchical vs. DBSCAN: Density vs. Distance
DBSCAN finds arbitrarily shaped clusters based on density and automatically identifies outliers. Use DBSCAN when:
- Your clusters have irregular, non-spherical shapes
- You expect noise and want to explicitly identify outliers
- Cluster size varies dramatically
Use hierarchical clustering when:
- You want every customer assigned to a segment (not labeled as noise)
- You need to understand relationships between segments
- Your data doesn't have clear density-based structure
Hierarchical vs. Gaussian Mixture Models: Hard vs. Soft Assignment
GMMs assign customers probabilistically. Each customer has a probability of belonging to each cluster. Use GMMs when:
- Customers genuinely exhibit mixed behaviors (belong partially to multiple segments)
- You want uncertainty estimates in cluster assignment
- Your data follows multivariate normal distributions
Use hierarchical clustering when:
- You need crisp segment assignments for operational execution
- You want visual interpretability (dendrograms)
- Your data doesn't meet normality assumptions
In practice, hierarchical clustering hits the sweet spot for customer segmentation: it's interpretable (dendrograms are intuitive), flexible (no assumptions about cluster shape), and comprehensive (reveals structure at all granularities). The main limitation is computational, but most customer segmentation projects comfortably fit within the size constraints.
Interpreting Results: From Statistics to Strategy
You have your dendrogram. You've cut it at the optimal height. You've profiled each segment with summary statistics. Now comes the translation: what do these segments mean, and what should you do about them?
This is where Sage Pearson's customer-centric perspective becomes essential. Behind every cluster is a group of customers who share characteristics and needs. Your job is to understand their story.
Name Segments Based on Behavior, Not Statistics
Don't name segments "Cluster 1" or "High-RFM Group." Give them names that capture the human behavior driving the pattern:
- "Deal Hunters": Low AOV, high frequency, purchase only during promotions
- "Considered Buyers": Low frequency, high AOV, extensive browsing before purchase
- "Loyal Regulars": High frequency, medium AOV, consistent purchase cadence
- "Lapsed Enthusiasts": Previously high engagement, recent drop-off, high historical value
These names communicate intent. When a marketing manager sees "Deal Hunters," they immediately understand the customer mindset and can brainstorm appropriate strategies. "Cluster 2 (low recency, medium frequency)" requires translation work.
Map Segments to Customer Journeys
Where do these segments sit in the customer lifecycle? Understanding this positioning informs strategy:
- New/Exploring: First purchase recently, low frequency → Focus on onboarding and second purchase
- Engaged/Growing: Increasing frequency or AOV → Nurture the relationship, remove friction
- Stable/Loyal: Consistent high value → Retention and referral programs
- At-Risk/Declining: Decreasing engagement → Win-back campaigns and feedback collection
- Churned/Lost: No recent activity → Reactivation offers or graceful offboarding
Your dendrogram might reveal that "At-Risk/Declining" actually contains two subsegments: one that's price-sensitive (will respond to discounts) and one that's product-dissatisfied (needs different offerings or service recovery). This nested structure drives tactical execution within your broader strategic framework.
Quantify Segment Value and Prioritize Resources
Not all segments deserve equal attention. Calculate segment-level metrics:
- Current value: Total revenue contribution
- Projected lifetime value: Expected future revenue
- Growth trajectory: Increasing, stable, or declining
- Retention cost: How expensive is it to keep them?
- Acquisition source: Where do these customers come from?
This analysis can show whether a group such as your "Loyal Regulars" accounts for a large share of revenue, and whether a group such as "Deal Hunters" costs more to serve. Compute these shares from your own data before deciding on resource allocation.
Building Automated Workflows from Hierarchical Structure
The true power of hierarchical clustering for modern analytics isn't just segmentation. It's automated decision-making based on segment position. The dendrogram becomes your decision tree, and cluster membership triggers specific workflows.
Dynamic Segmentation: Updating Cluster Assignments
Customer behavior changes. Someone in the "New/Exploring" segment makes their fifth purchase and should move to "Engaged/Growing." Automation handles this:
- Run hierarchical clustering monthly on your active customer base
- Store cluster centroids (average feature values per segment)
- Daily, calculate each customer's distance to each centroid
- Assign customers to the nearest cluster
- When cluster assignment changes, trigger transition workflow
This creates dynamic segmentation where customers flow between segments as behavior evolves, and each transition triggers appropriate messaging.
Multi-Level Targeting: Using the Full Hierarchy
Don't collapse the dendrogram to a single cluster level. Use the nested structure:
Example: Email campaign automation
Level 1 (3 clusters): Determines send frequency
- High-value → Daily emails allowed
- Medium-value → 3x per week
- Low-value → Weekly digest only
Level 2 (7 clusters): Determines content type
- High-value splits into "product enthusiasts" vs "deal seekers"
- Enthusiasts → New product announcements
- Deal seekers → Flash sales and promotions
Level 3 (12 clusters): Determines specific messaging
- "Product enthusiasts" splits by category preference
- Category A fans → Highlight Category A launches
- Multi-category buyers → Cross-sell recommendations
This hierarchy automates thousands of customer-specific decisions without manual intervention. The clustering structure itself encodes your targeting logic.
Propensity Scoring Within Segments
Hierarchical clustering identifies homogeneous groups. Within those groups, you can build highly accurate propensity models:
- Within "At-Risk" segment, build churn prediction model
- Within "Engaged/Growing" segment, build upsell propensity model
- Within "Loyal Regulars" segment, build referral likelihood model
Because segment members share behavioral patterns, models trained within segments often outperform global models trained on all customers. The hierarchical clustering handles the macro-segmentation; propensity models handle micro-targeting within segments.
Your turn
Bring your own data and the question you actually need answered.
MCP AnalyticsData science by email Send us your data and your question, and we will reply. ds@mcpanalytics.ai
Frequently Asked Questions
The Path Forward: From Clustering to Customer Understanding
Hierarchical clustering solves the problem that stymies most segmentation projects: how many customer groups actually exist? The dendrogram answers this question visually, revealing natural divisions in behavioral data and showing nested substructure that other algorithms miss.
But the real value isn't statistical, it's strategic. These segments tell you something important about customer needs. Behind each cluster is a group of people with shared characteristics, trying to accomplish similar goals, facing similar challenges. Understanding these patterns lets you automate the right interventions: nurturing campaigns for growing customers, retention offers for at-risk segments, premium experiences for loyal advocates.
The automation opportunities emerge from the hierarchy itself. Multi-level targeting uses the full dendrogram structure, not just a single cluster assignment. Customers near cluster boundaries get exploratory messaging. Customers deep within stable segments get confident, highly targeted campaigns. The tree structure becomes your decision logic, encoding thousands of customer-specific choices into reproducible workflows.
Start with solid features (RFM metrics, engagement indicators, product preferences) that capture meaningful behavioral dimensions. Apply agglomerative clustering with Ward's linkage as your default. Let the dendrogram show you where natural divisions occur. Then translate those statistical patterns into human stories: who are these customers, what do they need, and what should we do differently for each group?
That translation, from clusters to customer understanding, is where hierarchical clustering becomes powerful. The correlation suggests a behavioral pattern worth exploring. The dendrogram illuminates that pattern. Your insight turns it into action.
Clustering many correlated columns can be unstable, and one common step is to reduce them first with principal component analysis (PCA).