Cluster Analysis: Methods, Steps and a Worked K-Means Example

Cluster analysis groups items so that items in the same group are more alike than items in other groups. Nobody tells the method what the groups should be. It finds them in the data. That makes it useful for customer segmentation, defect pattern analysis, supplier grouping and many other problems.

This guide explains the main clustering methods, how to do clustering step by step, how to choose the number of clusters, and how to read the results. It includes a worked k-means example with the figures checked, and a section on where cluster analysis fits in Lean Six Sigma.

What Is Cluster Analysis?

Cluster analysis is an unsupervised method. You give it a set of items (customers, parts, orders, sites) and a few measured variables for each item. The method measures how close each item is to the others and forms groups of close items.

It differs from classification. In classification, the groups already exist and you train a model to sort new items into them. In clustering, you discover the groups.

QuestionCluster analysisClassification
Are the groups known in advance?NoYes
Type of methodUnsupervisedSupervised
Typical outputNew segments to describe and nameA label for each new item
ExampleFind natural customer segmentsPredict whether an order will be late

Types of Clustering Methods

MethodHow it worksStrengthsWatch out for
K-meansPlaces k centres, assigns each item to the nearest centre, moves centres to the mean of their items, and repeatsFast, simple, works on large data setsYou must choose k. Sensitive to outliers and to scale. Assumes round clusters
Hierarchical (agglomerative)Starts with every item alone and merges the closest pair again and again, shown as a dendrogramNo need to fix k first. The dendrogram is easy to explainSlow on very large data sets. Results depend on the linkage rule
DBSCAN (density based)Groups items in dense areas and labels isolated items as noiseFinds odd shapes and flags outliersNeeds two tuning settings. Struggles when density varies
Gaussian mixture modelsFits several overlapping normal distributions and gives each item a probability of belonging to eachSoft membership, handles oval clustersMore complex to explain and tune
K-modes and k-prototypesVersions of k-means for categorical or mixed dataWorks with categories such as region or product typeLess widely available in basic tools

How to Do Clustering: 7 Steps

Step 1: Define the objective

State what decision the clusters will support. For example, "Design three service levels for our customers" or "Find groups of defects with similar causes". The objective decides which variables matter.

Step 2: Choose and prepare the variables

Pick a small number of variables that relate to the objective. Remove duplicates, fix errors and decide how to handle missing values. Avoid using two variables that measure almost the same thing, because that gives the idea double weight.

Step 3: Standardise the variables

Variables on large scales (such as dollars) will dominate variables on small scales (such as years) unless you standardise. The usual method is the z-score: z = (value − mean) ÷ standard deviation. After this, every variable has a mean of 0 and a standard deviation of 1.

Step 4: Choose a distance measure and method

Euclidean distance (straight-line distance) is the default for numeric data. K-means is a good first choice for numeric data. Use hierarchical clustering when the data set is small and you want a dendrogram.

Step 5: Choose the number of clusters

Use more than one guide:

  • Elbow method: plot the within-cluster sum of squares (WCSS) for k = 1, 2, 3 and so on. Look for the point where the curve bends and extra clusters add little.
  • Silhouette score: ranges from −1 to 1. Higher means items sit well inside their own cluster and away from others.
  • Dendrogram: for hierarchical clustering, look for a long vertical gap where a horizontal cut gives clear groups.
  • Business sense: the clusters must be few enough and different enough to act on.

Step 6: Run the analysis

Run k-means several times from different random starts and keep the best solution. Most software does this for you.

Step 7: Profile, name and test the clusters

Calculate the average of each variable for each cluster, in the original units. Give each cluster a plain name. Then check with people who know the process whether the groups make sense and whether they would act differently for each group.

Worked Example: K-Means Customer Segmentation

Illustrative example with made-up data. A retailer wants to design service levels. It has four variables for ten customers.

CustomerAnnual spend ($)Visits per yearTenure (years)Product categories
11,2001534
23,5004056
3800812
45,2005278
51,1001223
64,8004867
7600612
83,2003545
99001023
105,0005088

Standardise

Annual spend has a mean of $2,630 and a sample standard deviation of about $1,911. Customer 4's z-score for spend is (5,200 − 2,630) ÷ 1,911 = 1.34. Customer 7's is (600 − 2,630) ÷ 1,911 = −1.06. The same is done for visits (mean 27.6, SD 19.1), tenure (mean 3.9, SD 2.51) and categories (mean 4.8, SD 2.35).

Choose k

Number of clusters (k)WCSSAverage silhouette
136.0n/a
25.460.69
31.840.66
40.980.59
50.590.48

WCSS drops sharply from k = 1 to k = 2, and again to k = 3, then levels off. The silhouette is highest at k = 2 and still strong at k = 3. Both are valid. The team picks k = 3 because it wants three service levels and the third cluster is clearly different.

Results

ClusterCustomersAvg spendAvg visitsAvg tenureAvg categories
A: Loyal high spenders4, 6, 10$5,000507.0 years7.7
B: Growing regulars2, 8$3,35037.54.5 years5.5
C: Occasional buyers1, 3, 5, 7, 9$92010.21.8 years2.8

Check one figure: cluster C spend = (1,200 + 800 + 1,100 + 600 + 900) ÷ 5 = 4,600 ÷ 5 = $920.

Act on the clusters

  • Cluster A: protect the relationship with a named contact and priority service.
  • Cluster B: cross-sell into more categories to move them towards cluster A.
  • Cluster C: make buying easy and low cost to serve, such as self-service ordering.

Common Problems and Fixes

ProblemFix
One variable dominates the clustersStandardise all variables first
Outliers pull k-means centresInvestigate them, cap extreme values, or use DBSCAN or k-medoids
Categorical data such as regionUse k-modes, k-prototypes or Gower distance
Different runs give different clustersUse many random starts and check the solution is stable
Clusters are hard to explainUse fewer, more meaningful variables and profile clusters in original units

Tools for Cluster Analysis

  • Minitab: Stat > Multivariate > Cluster Observations (hierarchical) or Cluster K-Means.
  • Python: scikit-learn provides KMeans, AgglomerativeClustering, DBSCAN and silhouette_score.
  • R: kmeans() and hclust() in base R.
  • Excel: possible for small data sets with Solver or add-ins, but slow to repeat.

Cluster Analysis in Lean Six Sigma

Cluster analysis is an Analyse phase tool. It helps a team see that one process is really several processes, each needing its own fix. Examples include:

  • grouping defects by temperature, humidity and material batch to find conditions that produce scrap
  • splitting customer orders into simple and complex types before setting cycle time targets
  • grouping sites or suppliers with similar performance to share good practice

It works well alongside data stratification, which splits data by known factors, and customer segmentation. If a histogram of your process looks like two humps, read about bimodal distributions: clustering can help explain where the two groups come from.

Multivariate tools such as cluster analysis are covered in the Lean Six Sigma Black Belt online training. The Green Belt online training covers the core data analysis skills that come first.

Frequently asked questions

What is cluster analysis?

Cluster analysis groups items so that those in the same group are more similar to each other than to items in other groups, without needing predefined labels.

How do you do clustering?

Choose the variables, standardise them, pick a method such as k-means or hierarchical clustering, decide the number of clusters, run the analysis, then describe and name each cluster.

How do you choose the number of clusters?

Use the elbow method on a plot of within-cluster sum of squares, silhouette scores, or a dendrogram for hierarchical clustering. Then check that the clusters make practical sense.

What is the difference between k-means and hierarchical clustering?

K-means needs you to choose the number of clusters first and works well on large data sets. Hierarchical clustering builds a tree of merges, so you can choose the number of clusters afterwards, but it is slower on large data.

Why do you standardise data before clustering?

Clustering uses distance. Without standardising, a variable measured in thousands of dollars would outweigh a variable measured in years, and the clusters would reflect only that one variable.

Is cluster analysis supervised or unsupervised?

It is unsupervised. The groups are not known in advance. The method discovers them from the data.

What is a practical example?

Grouping customers by spend, visits, tenure and range of products bought to design three service levels, as in the worked example above.