Cluster analysis

K-Means Cluster Analysis

Divides respondents into groups that resemble one another on the continuous variables you choose, and profiles each group against the overall average.

Method summary

K-means cluster analysis places every respondent as a point in the space formed by the chosen variables and distributes those points across a set number of groups. It works through cluster centres: each case is assigned to the nearest centre, the centres are recomputed as the average of the cases assigned to them, and the two steps repeat until the assignments settle. The panel standardises the variables by default so that a variable measured in thousands cannot steer the distance calculation on its own. If you do not supply a number of clusters, the engine sweeps from two to ten, computes the silhouette score for each and keeps the value scoring highest, listing the score of every k it tried. At the heart of the output sits the profile table: the variable means for each cluster and how far those means depart from the overall average. Naming the clusters is a matter of reading those departures, since the numbers themselves name nothing.

Which research questions does it answer?

  • How many distinct types do my customers fall into on attitude and usage measures, and what separates them?
  • Are there pockets of respondents who answer the brand perception scales in similar ways?
  • Which target audiences emerge once price sensitivity and quality expectation are considered together?
  • Do usage frequency and satisfaction measures yield segments worth addressing separately in communication?

When should you use it?

  • When respondents should be grouped from the measured variables themselves, with no predefined grouping variable at hand.
  • When at least two numeric variables are available for clustering; the engine refuses to run on a single variable.
  • When it is reasonable to expect clusters of roughly similar spread and compact shape, since the method rests on distance from a centre.
  • When the number of segments should come from the data; leaving the cluster count empty triggers automatic selection on the silhouette score.
  • When the resulting clusters are meant to serve as a grouping variable later, since every case comes back with a cluster label.

Required variable types

  • Every column entering the clustering must be numeric; setting the measurement level to 'scale' on the Variable tab lets the method picker offer it.
  • At least two variables are required. There is no dependent and independent split and no outcome variable is chosen.
  • Categorical variables are not accepted as input. Columns such as gender or region serve to describe the resulting clusters afterwards rather than to build them.
  • One row per respondent, and a row missing a value on any selected variable drops out of the analysis entirely.

Key assumptions

Variables on comparable scales
The distance calculation is sensitive to units. A variable measured in thousands, such as income, will define the clusters by itself when it enters the same computation as a seven-point attitude scale.
Compact cluster shapes
Because each case goes to the nearest centre, the method presumes roughly spherical clusters of similar spread. Crescent-shaped or nested structures are not separated correctly by this approach.
A genuine grouping structure
The method never asks whether groups exist; it produces the number requested. Even homogeneous data drawn from one population yields clusters, but those clusters shift from sample to sample.
Absence of extreme cases
Since centres are computed as averages, a single extreme case can pull a centre towards itself and give rise to a tiny cluster made up of little more than that case.
No heavy redundancy among the variables
When several variables measure the same thing, that dimension multiplies its weight in the distance calculation and the clusters end up organised around it.

How YouReply checks these assumptions

  • Variables on comparable scales: Standardisation is on by default and brings the variables onto the same scale before clustering. It can be switched off, but then the influence of differing units is for the researcher to judge.
  • Compact cluster shapes: The panel does not check this assumption automatically; the researcher evaluates it.
  • A genuine grouping structure: The silhouette score is computed on every run and stays low where separation is weak. When the cluster count is chosen automatically, the silhouette of every k tried is listed, so you can see the case where all the scores are low and close to one another.
  • Absence of extreme cases: No outlier screening happens inside this method. Cluster sizes are reported, so if you see a cluster holding one or two cases it is worth running outlier detection separately.
  • No heavy redundancy among the variables: The panel does not inspect correlations among the variables in this method. To reduce an item pool to dimensions first, factor analysis and principal component analysis are offered as separate methods.

How the analysis is run

  1. 1Drop your CSV or XLSX file onto the panel, arranged with respondents in rows and variables in columns.
  2. 2On the Variable tab set the clustering columns to the 'scale' level, declare missing value codes as missing, and build composite scores with derived columns if you need them.
  3. 3Open the method picker on the Analysis tab and take this method from the cluster analysis category; the data requirements box states that at least two numeric columns are needed.
  4. 4Tick the clustering variables in the parameter form. Leaving the cluster count empty sweeps from two to ten and keeps the k with the highest silhouette score.
  5. 5Leave standardisation on, or switch it off if every variable is already on the same scale. The random seed defaults to 42, which is what makes a repeated run on the same data return the same solution.
  6. 6Start the run. The result lists cluster sizes, the profile table, the quality measures, the silhouette scores of the cluster counts tried and the per-case labels in collapsible sections.
  7. 7Read the profile table, name the clusters, and download the tables as Excel. No chart is drawn for this method; the computation credits card names the library call and its version, and the history tab keeps earlier runs.

Statistics and tables produced

Details of the solution
The number of complete observations used, the number of clusters, and whether that number was chosen automatically or supplied by you.
Cluster sizes
The case count in each cluster and its share of the total. A very small cluster is usually where extreme cases have collected.
Cluster profile table
For each cluster, the mean of every variable and how far that mean departs from the overall average. Naming the clusters rests on these departures.
Quality measures
The silhouette score, the Calinski-Harabasz index and the Davies-Bouldin index. Where they cannot be computed no value is invented and the field comes back empty.
Scores of the cluster counts tried
When the count is chosen automatically, the silhouette score for each k between two and ten. The selection follows the highest score.
Cluster label per case
Which cluster each case was assigned to, plus the index of the rows retained. The labels in the Excel export can be matched back to your own data.
Inertia
The sum of squared distances from cases to their own cluster centre. It falls on its own as clusters are added, which is why it is not a quality measure in itself.

Effect size and confidence intervals

Silhouette score
Compares how close each case sits to its own cluster against how close it sits to the nearest neighbouring cluster, on a range from minus one to plus one. Values near zero mean the boundaries are blurred, while values above 0.50 indicate clear separation. This is the quantity that judges how well separated a solution is, and the automatic choice of cluster count rests on it.
Calinski-Harabasz index
The ratio of between-cluster spread to within-cluster spread, with no upper bound, where larger values mean better separation. Having no absolute benchmark, it serves to compare different cluster counts on the same data and cannot be compared across datasets.
Davies-Bouldin index
The average overlap between each cluster and the cluster it most resembles, and unlike the other two, smaller is better. Values approaching zero say the clusters are far apart and tight within themselves.

Cluster analysis returns no confidence interval for any output and performs no significance test. Cluster means, departures from the overall average and the quality measures are all point estimates, and no standard errors are given. This follows from the nature of the method: because the clusters are derived from the data, testing the significance of differences between them on the same data is circular reasoning and makes the p value look smaller than it is. To gauge how stable a solution is, split the sample and repeat the analysis on each half, or run it with different random seeds and see whether the profile table holds. Where a formal test of cluster differences is needed, it belongs on a variable that was kept out of the clustering.

Example research question and example result

The numbers below are a representative example, not data from a real study or a real user.

Research question
In a retail customer study, how many segments do respondents form on price sensitivity, quality expectation and shopping frequency? (Illustrative example, not real data.)
Variables
Price sensitivity: the mean of three items, 1 to 7 · Quality expectation: the mean of four items, 1 to 7 · Monthly shopping frequency: the number of visits as reported · 612 complete responses, cluster count left empty, standardisation on
Example result
The sweep tried two to ten clusters and found the highest silhouette at three: 0.38 for k = 2, 0.47 for k = 3, 0.41 for k = 4, with lower scores thereafter. In the three-cluster solution the sizes were 241 (39.4%), 208 (34.0%) and 163 (26.6%). In the profile table the first cluster sits 1.12 points above the overall average on price sensitivity and 0.74 points below it on quality expectation; the second sits 0.93 points above on quality expectation and 2.4 visits above on shopping frequency; the third stays close to the overall average on all three variables. The quality measures were silhouette 0.47, Calinski-Harabasz 284.6, Davies-Bouldin 0.82.
Interpretation
The silhouette peaks at three clusters, and 0.47 corresponds to moderate separation, meaning the clusters are distinguishable without having sharp boundaries. The profile table makes naming possible: the first cluster is a price-led audience willing to compromise on quality, the second a quality-led audience that shops often, and the third a middle group with no pronounced tendency. A cluster sitting close to the overall average is a common and unremarkable outcome rather than a failure of the clustering, although any segmentation decision needs a deliberate answer for which channel that group belongs to. To gauge stability it is worth splitting the sample, repeating the analysis and checking whether the profile table keeps its shape.

Real output on a sample dataset

The results below were produced by the analysis engine from this data file. Changing the variable changes the research question as well; every run was computed in advance, so the page sends no request to the engine.

Variable examined

General customer survey (synthetic)

A wide survey of three hundred respondents: two and three category grouping variables, continuous measures, a five point ordinal scale, a binary purchase outcome, a four category brand choice, three repeated measurements, paired binary questions, three raters, four price questions and deliberately empty cells.

Rows
300
Columns
respondent_id, gender, education, region, age, income, satisfaction, service_score, price_score, quality_score, loyalty, nps_score, purchased, brand_choice, satisfaction_level, pre_score, post_score, measure_1, measure_2, measure_3, use_before, use_after, use_followup, rater_1, rater_2, rater_3, price_too_cheap, price_cheap, price_expensive, price_too_expensive, feedback_score, followup_rating
Download the dataset as CSV

The data is synthetic: it comes from a fixed random seed, not from a real study. The values below were produced by the analysis engine from this file, so uploading the same file to the panel gives the same results.

Research question: How many customer clusters best fit the data in terms of satisfaction and perception scores?

Analyzed variables
satisfaction,service_score,price_score,quality_score,loyalty
Standardize the variables
true
Random seed
42
Cases analyzed
300
Number of clusters
2
Number of clusters selected automatically
Yes
Variables standardized
Yes
Within-cluster sum of squares
1,149.29

Silhouette score per number of clusters

Silhouette score per number of clusters
Number of clusters tried (k)Silhouette score
20.207
30.196
40.199
50.182
60.176
70.179
80.179
90.171
100.173

Cluster sizes

0
145
1
155

Cluster profiles

Cluster profiles
ClusterSizeProportionCluster meansDeviation from the overall mean
01450.483--
11550.517--

Cluster quality measures

Silhouette score
0.207
Calinski-Harabasz index (higher is better)
90.94
Davies-Bouldin index (lower is better)
1.72

Computation credits: scipy 1.18.0 · statsmodels 0.14.6 · scikit-learn 1.9.0 · numpy 2.5.1 · pandas 3.0.5 · semopy 2.3.11 · 89fc29a · Data seed: 20260914

How to report the result

Six hundred and twelve respondents were clustered with k-means on three standardised variables; the silhouette score favoured a three-cluster solution (silhouette 0.47), with clusters of 241, 208 and 163 cases.

An example sentence close to APA style; the numbers are representative.

When you should not use it

  • It does not test whether a grouping structure exists. The requested number of clusters is produced in every case, including on homogeneous data.
  • Resting on distance from a centre, the method presumes roughly spherical clusters of similar size. Elongated or nested structures are split incorrectly.
  • The choice of cluster count rests on the silhouette score alone. The elbow method is not applied and no elbow plot is drawn, so how inertia changes with the cluster count cannot be inspected visually.
  • Categorical variables cannot enter the clustering, and no significance test or confidence interval accompanies the differences between clusters; the departures in the profile table are judged by eye.
  • A row missing a value on any selected variable is dropped in full, so the solution may rest on a progressively narrower and self-selected subset of the data.
  • The result depends on the random start. Because the seed is fixed by default, the same data gives the same solution, but changing the seed can renumber the clusters and move borderline cases.

What to use when the assumptions are not met

  • Hierarchical Cluster AnalysisWhy: When the merge structure is a better way in than committing to a cluster count up front, or when the sample is small.
  • Exploratory Factor Analysis (EFA)Why: When what needs grouping is the items rather than the respondents; it shows how many dimensions an item pool reduces to.
  • Principal Component Analysis (PCA)Why: When a large set of overlapping variables should be condensed into a few components before clustering.
  • Cross-TabulationWhy: When the segments are already defined and the question is how they relate to demographic variables.

Frequently asked questions

How many clusters should I keep?
Leave the cluster count empty and the engine sweeps from two to ten, keeping the value with the highest silhouette score; the score for every k tried appears in the result, so you can see how clear-cut the decision was. Where the scores sit close together the data supports several solutions about equally, and interpretability then decides: each cluster should have a distinctive story in the profile table and be large enough to address separately in practice. Clusters of one or two cases are of no practical use. Once you have decided, enter the count by hand and run the analysis again.
Should I standardise the variables?
Standardisation is on by default and in most situations should stay on. Distance is scale-sensitive, so an income variable measured in thousands will all but determine the clusters when it enters the same analysis as a seven-point attitude scale. The one case for switching it off is when every variable already shares a scale and a spread, items from the same seven-point format for instance, where the differences in raw spread can be treated as information. If you do switch it off, run the solution both ways and compare the profile tables.
How can I show that the differences between clusters are significant?
Testing significance on the clustering variables themselves is misleading, because the clusters were built precisely to separate on those variables; the result comes out significant almost always and proves nothing. A meaningful test uses a variable that was kept out of the clustering: where clusters are built from attitude scales, one-way analysis of variance can ask whether they differ in actual purchase value or renewal rate. Since every case comes back with a cluster label, that label can serve as the grouping variable.
Will the same data give me the same clusters every time?
The random seed is held at 42 by default, so the same data, the same variables and the same cluster count return the same solution. Change the seed and the cluster numbering may shuffle while a few borderline cases move across; in a stable solution the broad pattern of the profile table stays put. That is the practical way to judge robustness: run it with different seeds and see whether the story of the clusters holds, or split the sample and confirm that similar profiles emerge in each half.

References

Try it with your own data

The free plan includes 50 analysis runs a month and needs no card.