Customer segments with clustering
In one retailer's orders, none of 24 silhouette-picked clusterings predicted reorders better than a recency-and-value rule; 29 of 96 with 5 to 8 segments did, by 0.01 to 0.04 AUC.
Main limitation One wholesaler-heavy UK gift-ware retailer and two decision dates; the gains are a few hundredths of AUC.
AUC for ordering again within 180 days, minus the rule's 0.73; 4,315 customers, 95% intervals
Show the data
| Segments | AUC | Minus the rule | Interval | Stability (ARI) |
|---|---|---|---|---|
| 2 (silhouette pick) | 0.689 | −0.038 | −0.052 to −0.022 | 0.97 |
| 3 | 0.731 | +0.004 | −0.008 to +0.018 | 0.94 |
| 4 | 0.737 | +0.011 | −0.002 to +0.023 | 0.95 |
| 5 | 0.751 | +0.025 | +0.013 to +0.037 | 0.86 |
| 6 | 0.757 | +0.030 | +0.019 to +0.041 | 0.70 |
| 7 | 0.762 | +0.036 | +0.025 to +0.046 | 0.80 |
| 8 | 0.758 | +0.032 | +0.021 to +0.043 | 0.81 |
| Trained model | 0.784 | +0.057 | +0.046 to +0.070 | |
| Recency alone | 0.729 | +0.003 | −0.010 to +0.014 | |
| The rule | 0.727 | 0 | 0.99 |
Intervals resample customers with the segments held fixed. The trained model and recency alone have no segments, so no stability.
Clustering's usual default, the silhouette score, mostly split the 4,315 active customers into two groups: recent, frequent buyers and the rest. Those segments separated who ordered again in the six months after 1 June 2011, a period the clustering never saw, less well than the study's six-cell rule (AUC 0.69 against 0.73 for k-means on recency, frequency and value). With 5 to 8 segments, 29 of the 96 clusterings beat the rule with intervals above zero, all of them on recency and value: 13 on those two alone, 15 with frequency added and 1 with product mix as well, from k-means, the mixture and Ward; none from average linkage, raw values or product mix alone. k-means on recency, frequency and value beat it by 0.025 to 0.036, at lower stability; a model trained for the outcome beat it by 0.06.
| Default clusterings above the rule 0 of 24 at the segment count their silhouette picked, on 1 June 2011 (every interval below zero) and again on 1 December 2010, where every point estimate is below the rule and 3 intervals reach zero (k-means, percentile ranks: recency and value, 4 segments; k-means, logs and z-scores: recency, frequency, value and product mix, 4 segments; k-means, percentile ranks: recency, frequency, value and product mix, 3 segments) | Above the rule at 5 to 8 segments 29 of 96 clusterings whose interval lies above zero, by +0.013 to +0.036 AUC over the rule's 0.73 (27 in December). k-means on recency, frequency and value: +0.025 to +0.036 (+0.018 to +0.036 in December); its stability falls from 0.97 at 2 segments to 0.70 to 0.86 | Stability (adjusted Rand index) 0.86 to above 0.99 k-means and the mixture on logs and z-scores at their silhouette pick, over 100 resamples; Ward 0.22 to 0.64, average linkage 0.08 to 0.49; the rule 0.99 | No segment to win back 17 of 24 default clusterings had no segment that was both quiet and at or above the median past-year revenue, so a team reading them would contact no one; the rule lists 330 |
Terms used on this page
- Segment
- A group of customers that a clustering algorithm puts together because their features are close.
- The rule
- The first part's hand-built cut: three value tiers (top 10%, next 20%, bottom 70% by past-year revenue) times quiet or recent, six cells in all.
- Silhouette
- A score of how well separated the segments are; picking the number of segments with the highest score is the usual default.
- AUC
- The chance that a customer who ordered again gets a higher score than one who did not: 0.5 is a coin toss, 1 is perfect. Here a customer's score is the share of its segment that ordered again, estimated on other customers.
- Adjusted Rand index (ARI)
- How far two segmentations of the same customers agree, corrected for chance: 1 is identical, 0 is no better than random.
- Win-back list
- The customers a team would contact: here, every member of a segment whose median customer has not ordered for over 90 days and spent at least the median past-year revenue.
One customer, four feature sets
A customer on the rule's list on 1 June 2011: last order about 25 weeks before, 5 to 9 orders and about £1,800 in the past year (next 20% by revenue), about 18 units a line at a median £1.60, 50 to 99 products, about 40% of the year's buying in September to November.
On recency and value alone, k-means puts this customer with 2,758 mostly quiet, small buyers (median 194 days since the last order, £382). Add how often they ordered and the same customer moves to a segment of 1,502 frequent buyers whose median last order was 24 days before. Neither segment is quiet and valuable, and none of the four segments in the table reaches a win-back list; the rule lists this customer because it reads recency and value separately.
| Features | Segments | The customer's segment | On a win-back list |
|---|---|---|---|
| Recency and value | 2 | 2,758 customers; medians 194 days since the last order, 1 order, £382 in the past year | No |
| Recency, frequency, value | 2 | 1,502 customers; medians 24 days since the last order, 6 orders, £2,019 in the past year | No |
| Recency, frequency, value, product mix | 4 | 1,394 customers; medians 26 days since the last order, 6 orders, £2,124 in the past year | No |
| Product mix only | 4 | 1,865 customers; medians 51 days since the last order, 4 orders, £1,329 in the past year | No |
The customer was chosen by a rule set before any fit: the list customer closest to the list's median recency and value, among those whose win-back status changes between feature sets. No list customer's status changed (at the silhouette pick none of the four k-means fits has a win-back segment), so the closest one overall. Counts are shown in bands and the other features rounded, so the customer cannot be picked out of the public file, and the key is not shown.
Features, scaling and distance
Every clustering at its silhouette pick scored below the rule; the worst were the ones that left one giant segment.
- Scaling decides first. On raw values (pounds next to days and counts) k-means at the silhouette pick puts 99% or more of customers in one segment and scores an AUC of 0.49 or less, a coin toss: the other segment holds a handful of customers, under 11 on three of the four feature sets.
- Distance and linkage. Average linkage with Manhattan distance also leaves one giant segment and a few stragglers at the silhouette pick. Ward linkage builds segments of workable size, but they change with each resample.
- Features. For k-means on logs and z-scores, product mix alone (units per line, unit price, range of products, autumn share) separates later ordering least of the four feature sets: AUC 0.65 against 0.68 to 0.70. It describes what customers buy, not whether they are still buying.
- Number of segments. The silhouette picked two segments in 20 of 24 cases. More segments separated better: 44 of the 168 fits at this date beat the rule, all with 3 or more segments, none of them the silhouette pick. That count was not a prediction, and picking the count by the outcome would be picking on the test.
AUC minus the rule's; 95% intervals
Show the data
| Clustering | Segments | AUC | Minus the rule | Stability (ARI) | AUC, 1 December 2010 |
|---|---|---|---|---|---|
| k-means, logs and z-scores: recency and value | 2 | 0.68 | −0.04 | 0.98 | 0.68 (2 segments) |
| k-means, raw values: recency and value | 2 | 0.49 | −0.24 | 0.73 | 0.49 (2 segments) |
| k-means, percentile ranks: recency and value | 2 | 0.71 | −0.02 | 0.97 | 0.73 (4 segments) |
| Gaussian mixture: recency and value | 2 | 0.66 | −0.07 | 0.98 | 0.64 (2 segments) |
| Ward hierarchical: recency and value | 2 | 0.68 | −0.05 | 0.64 | 0.63 (2 segments) |
| Average linkage, Manhattan: recency and value | 2 | 0.49 | −0.24 | 0.19 | 0.49 (2 segments) |
| k-means, logs and z-scores: recency, frequency and value | 2 | 0.69 | −0.04 | 0.97 | 0.69 (2 segments) |
| k-means, raw values: recency, frequency and value | 2 | 0.49 | −0.24 | 0.71 | 0.49 (2 segments) |
| k-means, percentile ranks: recency, frequency and value | 2 | 0.70 | −0.03 | 0.99 | 0.70 (2 segments) |
| Gaussian mixture: recency, frequency and value | 2 | 0.66 | −0.07 | 0.94 | 0.68 (2 segments) |
| Ward hierarchical: recency, frequency and value | 2 | 0.65 | −0.08 | 0.52 | 0.68 (2 segments) |
| Average linkage, Manhattan: recency, frequency and value | 2 | 0.49 | −0.24 | 0.08 | 0.50 (2 segments) |
| k-means, logs and z-scores: recency, frequency, value and product mix | 4 | 0.70 | −0.02 | 0.93 | 0.72 (4 segments) |
| k-means, raw values: recency, frequency, value and product mix | 2 | 0.49 | −0.24 | 0.75 | 0.49 (2 segments) |
| k-means, percentile ranks: recency, frequency, value and product mix | 2 | 0.70 | −0.03 | 0.98 | 0.72 (3 segments) |
| Gaussian mixture: recency, frequency, value and product mix | 3 | 0.68 | −0.05 | 1.00 | 0.69 (3 segments) |
| Ward hierarchical: recency, frequency, value and product mix | 2 | 0.66 | −0.07 | 0.41 | 0.70 (3 segments) |
| Average linkage, Manhattan: recency, frequency, value and product mix | 2 | 0.49 | −0.24 | 0.29 | 0.49 (2 segments) |
| k-means, logs and z-scores: product mix only | 4 | 0.65 | −0.08 | 0.86 | 0.62 (4 segments) |
| k-means, raw values: product mix only | 2 | 0.49 | −0.24 | 0.67 | 0.49 (2 segments) |
| k-means, percentile ranks: product mix only | 7 | 0.67 | −0.05 | 0.81 | 0.69 (8 segments) |
| Gaussian mixture: product mix only | 2 | 0.58 | −0.14 | 0.97 | 0.63 (2 segments) |
| Ward hierarchical: product mix only | 2 | 0.57 | −0.16 | 0.22 | 0.67 (4 segments) |
| Average linkage, Manhattan: product mix only | 2 | 0.49 | −0.24 | 0.49 | 0.49 (2 segments) |
The rule's AUC is 0.73 on 1 June 2011 and 0.73 on 1 December 2010. Stability was measured at the June date only.
Stability across resamples
Refit on 100 resamples of the customers, k-means and the mixture mostly give the same segments; the hierarchical fits do not.
Each fit was rerun on 100 bootstrap resamples of the 4,315 customers, and every customer assigned to a segment of each refit. The adjusted Rand index compares those segments with the full-data ones. The rule, refit by setting its revenue cut points on each resample, scored 0.99; 97% of customers stayed in their cell in at least 90 of 100 resamples. For k-means on recency, frequency and value, 98% stayed in their segment at 2 segments and 64% at 7.
| Algorithm | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|
| k-means, logs and z-scores | 0.97 | 0.94 | 0.95 | 0.86 | 0.70 | 0.80 | 0.81 |
| Gaussian mixture | 0.94 | 0.78 | 0.88 | 0.81 | 0.86 | 0.93 | 0.93 |
| Ward hierarchical | 0.52 | 0.42 | 0.50 | 0.49 | 0.48 | 0.49 | 0.47 |
| Average linkage, Manhattan | 0.08 | 0.07 | 0.57 | 0.64 | 0.64 | 0.61 | 0.59 |
Who would get a contact
Read the usual way, the default segments either name no one to win back or name almost everyone.
A team turning segments into a contact list needs a rule; the one set in advance picks every segment whose median customer has not ordered for over 90 days and spent at least the median past-year revenue. At the silhouette pick, 17 of the 24 clusterings have no such segment: two segments split recent from quiet, and the quiet half is mostly small buyers. The lists that do appear come from product mix or from one giant segment, and they overlap the rule's list by under a tenth.
Across all 168 fits at this date, 94 gave a list and none met the first part's bar (at least 50% of the lost revenue with at most 35% of quiet customers). The best within the size cap, k-means, logs and z-scores: recency and value with 7 segments, listed 759 customers and held 49.6% of the lost revenue, against the rule's 38% with 330. That comparison was added after the results.
| Clustering | Segments | On the list | Overlap | Lost revenue held | Not yet quiet |
|---|---|---|---|---|---|
| k-means, logs and z-scores: recency and value | 2 | No segment qualifies | |||
| Gaussian mixture: recency and value | 2 | No segment qualifies | |||
| Ward hierarchical: recency and value | 2 | No segment qualifies | |||
| Average linkage, Manhattan: recency and value | 2 | 4,298 | 0.08 | 100% | 45% |
| k-means, logs and z-scores: recency, frequency and value | 2 | No segment qualifies | |||
| Gaussian mixture: recency, frequency and value | 2 | No segment qualifies | |||
| Ward hierarchical: recency, frequency and value | 2 | No segment qualifies | |||
| Average linkage, Manhattan: recency, frequency and value | 2 | No segment qualifies | |||
| k-means, logs and z-scores: recency, frequency, value and product mix | 4 | No segment qualifies | |||
| Gaussian mixture: recency, frequency, value and product mix | 3 | No segment qualifies | |||
| Ward hierarchical: recency, frequency, value and product mix | 2 | No segment qualifies | |||
| Average linkage, Manhattan: recency, frequency, value and product mix | 2 | 4,305 | 0.08 | 100% | 45% |
| k-means, logs and z-scores: product mix only | 4 | No segment qualifies | |||
| Gaussian mixture: product mix only | 2 | 2,870 | 0.10 | 76% | 43% |
| Ward hierarchical: product mix only | 2 | 3,081 | 0.09 | 70% | 45% |
| Average linkage, Manhattan: product mix only | 2 | 4,305 | 0.08 | 100% | 45% |
| The rule's list | 6 cells | 330 | 1 | 38% | 0% |
What I expected, and what happened
9 of 15 predictions held, 4 missed and 2 could not be tested.
The misses say the default clusterings did worse than I expected against the rule, the mixture was steadier than I expected on product mix, and average linkage was less lopsided. The two untestable ones failed for the reason the page is about: at the silhouette pick there was no win-back segment to compare.
| Prediction | Result | Estimate | Note |
|---|---|---|---|
| k-means on recency, frequency and value, at the silhouette pick, lands within 0.03 of the rule's AUC | Missed | −0.038 (interval −0.052 to −0.022) | below the band: the two segments separate less than the rule |
| No clustering at its silhouette pick beats the rule's AUC by more than 0.03 | Held | −0.018 | |
| The trained model beats the rule by at least 0.04, and every clustering at its silhouette pick | Held | +0.057 (interval +0.046 to +0.070) | the interval stays above the band |
| Recency alone is no more than 0.02 below the rule's AUC | Held | +0.003 (interval −0.010 to +0.014) | |
| Every product-mix clustering at its silhouette pick is at least 0.05 below the rule's AUC | Held | −0.054 | |
| k-means on recency, frequency and value: stability at least 0.80 at 2, 3 and 4 segments | Held | 0.94 | |
| The same at 8 segments is at least 0.10 below 3 segments | Held | −0.13 | |
| At 4 segments the mixture is less stable than k-means on every feature set | Missed | +0.11 | on product mix alone the mixture was the more stable |
| k-means on raw values puts at least 90% of customers in one segment at 2 to 5 segments | Held | 92% | close to a safe bet: on raw values the largest-variance feature, money, decides |
| Average linkage with Manhattan distance puts at least 90% in one segment at 4 segments, every feature set | Missed | 68% | on recency, frequency and value its largest segment held less than 90% |
| The silhouette picks 2 or 3 segments in at least 12 of the 16 logs-and-z-scores fits | Held | 14 | |
| The k-means list on recency and value overlaps the rule's list by at least 0.4 | Untestable | none | no segment met the win-back rule, so there was no list to compare |
| The k-means list on product mix overlaps the rule's list by at most 0.2 | Untestable | none | no segment met the win-back rule, so there was no list to compare |
| No logs-and-z-scores clustering at its silhouette pick gives a list that meets the first part's bar | Held | 0 | held, but only 5 of the 16 gave a list at all |
| On 1 December 2010, k-means on recency, frequency and value lands within 0.03 of the rule's AUC | Missed | −0.033 (interval −0.048 to −0.019) | below the band, as in June |
What a team should do with this
- Keep the simple rule as the baseline. Here a six-cell recency-and-value rule, and days since the last order alone, separated later ordering as well as or better than every default clustering. Any segmentation that replaces a rule should beat it on months it never saw.
- Do not let the silhouette pick the number of segments for a decision. It rewards clean splits, and the cleanest split here was recent against quiet. Choose the count by stability and by usefulness on held-out months, set in advance.
- Scale before clustering, and check the segment sizes. Raw money next to days gives one segment of almost everyone; logs, z-scores or ranks fix that.
- Check stability before naming segments. A segment that moves when the customers are resampled will not be the same segment next quarter; here k-means and the mixture held, hierarchical fits did not.
- For a contact list, score the outcome directly. A model trained for ordering again beat every segmentation. Use segments to describe customers, and a trained score, checked against a holdout group, to decide whom to contact.
Limits
- One UK online gift-ware retailer with many wholesale buyers, two decision dates in different seasons. Another business can rank the methods differently.
- The AUC gaps are a few hundredths. Intervals resample customers with the segments held fixed: they show sampling of customers, not how much a refit would move the score.
- The win-back list comes from one declared rule for reading segments. A team that reads segment profiles another way would contact other customers; the point is that the list moves with every choice above.
- "Ordered again" counts any order with no contact recorded; the data has no contacts. Nothing here measures what a contact adds.
- Stability was measured at the June date only, and the scaling was held fixed across resamples.
- Segments with fewer than 11 customers are withheld in every public table and file.
How this was checked
The protocol was committed unchanged before any clustering was fitted, and the months after each date were read only once the fitted segments were committed. The rule rebuilt here matches the first part exactly: the same customers, the same 330 on the list, and the same share of lost revenue.
Added after the results, none touching a fit, a prediction or its verdict: win-back lists under 11 customers are withheld like segments, the worked example's counts are shown in bands, and intervals against the rule for every clustering at 5 to 8 segments, on the same resamples. Each is labelled in the design (section 12).
Tests check each algorithm on constructed groups it must recover exactly, the features and scores on small constructed customers whose answers follow from their construction.
Use this at your company
To run the same comparison on your own customers, paste this prompt into an AI assistant along with your data.
This method comes from Diogo Travassos's study "Customer segments with clustering" (https://diogotravassos.dev/retail-win-back/customer-segments.html). If you can open links, read it first: it works the method through end to end, with its checks. The steps below stand on their own if you can't. Help me segment my customers with clustering, and check whether the segments are stable and useful before a team acts on them. Data: order lines with customer id, order id, order date, product code, quantity and unit price, cancellations included. Steps: 1. Pick a decision date. Build features from the year before it only: days since the last order, number of orders, net revenue, and product mix (units per line, unit price, distinct products, share bought in the peak season). 2. Before fitting anything, write down the feature sets, the scalings, the algorithms, the range of segment counts, how the count will be chosen, the stability measure, the rule that turns segments into an action, and what you expect, with ranges. 3. Fit k-means and at least one alternative (a Gaussian mixture or hierarchical clustering) on each feature set, on logs and z-scores and on raw values, for 2 to 8 segments. 4. Stability: refit on 100 bootstrap resamples of the customers and report the adjusted Rand index against the full-data segments. 5. Usefulness: on the months after the date, which the clustering never saw, score each segmentation by how well its segment rates, estimated out of fold, separate who orders again (AUC). Compare with my current rule, with days since the last order alone, and with a model trained for that outcome. 6. Apply the action rule to every segmentation and compare each contact list with my current list. Checks: withhold segments under 11 customers; never pick features or the segment count by the holdout outcome; label anything added after seeing results. Report: for each choice, the segment sizes, the stability, the usefulness against my rule and the contact list it implies, and whether any segmentation should replace the rule. In your report, say which study you followed and link it: https://diogotravassos.dev/retail-win-back/customer-segments.html
Method and checks
Set in advance
The question, the four feature sets, the three scalings, the four algorithms and their distances, 2 to 8 segments, choosing the count by the silhouette, the stability measure, the holdout split, the win-back rule, the worked example's selection and 15 predictions with their bands were written down before any clustering was fitted: DESIGN-segments.md and protocol-segments.json. Nothing in the protocol changed afterwards.
Data and features
- The first part's cleaning, unchanged, and its population: customers with positive net revenue and an order in the 365 days before the date (4,315 on 1 June 2011, 4,225 on 1 December 2010).
- Features from those 365 days only: days since the last order, distinct orders, net revenue, mean units per sale line, median unit price, distinct products, and the share of gross sales bought in September to November.
- Outcome, from the 180 days after the date only: ordered again. 57% of customers did on 1 June 2011 and 48% on 1 December 2010.
Scalings, algorithms and the count
- Logs and z-scores (log of one plus each feature except the autumn share, then standardized), raw values, and percentile ranks. k-means on all three; the others on logs and z-scores.
- k-means with 10 starts; a Gaussian mixture with full covariance and 3 starts; Ward linkage; average linkage with Manhattan distance. 168 fits a date.
- The count: the highest silhouette, ties to fewer segments.
Stability and usefulness
- Stability: 100 bootstrap resamples; each refit assigns every customer (the hierarchical fits by the nearest segment centre); mean adjusted Rand index against the full-data segments, and the share of customers in their matched segment in at least 90 of the resamples.
- Usefulness: 5 folds of customers; a customer's score is its segment's share that ordered again among the other folds. AUC over all customers, and over quiet customers only: there the rule scored 0.56 and recency alone 0.62.
- Intervals: 1,000 paired resamples of customers, scores held fixed.
- References: the rule's six cells; days since the last order alone; a logistic regression on all seven features, trained out of fold.
Added after the results
The comparison of the best list within the size cap against the rule's list, and the count of fits above the rule across all segment counts, are descriptions of declared fits added after the results; neither is scored.
Reproduce it
make segments rebuilds the features, fits and stability from the public download, and make segments-score scores the holdout period and renders this page. The packages are pinned with hashes in requirements-segments.lock. No key and no network beyond the data download.
Reproduce itThe designThe protocolThe segments (no outcome)The scoresPart one: win-backPart two: lifecycle accountingPart three: subscription lifecycle