Results

How a clustering's success is measured

With a referee, without one, and by the decision: what tells us a clustering is good? The referee-free measures disagree. In Initial Allocation the share by sales-mix cluster beats Lumoda's groups and store plan on availability, matches the store's own history, and trails the model.

Store Grouping · 6 / 6

Over five articles we split stores into clustersA group of stores with similar sales mixes. The plan and the initial allocation treat the stores in a cluster as one unit.: by region, by sales volume grade, by the grid of the two, by location, and with clusters found from the sales mix. We looked at how well the clusters hold from year to year and where a new store should go, and we built a share by cluster. Now we add up the account.

There are three ways to measure whether a clustering is good. In this series we used all three. In a real chain only two of them will be in your hands.

With a referee: against the answer key

The first way is the easiest, but it does not exist in real life. Lumoda is a synthetic chain and I generated its data; I gave every store a customer profile that does not appear in the published data. We measured the clusters against this answer key through ARI: 1 is a split exactly the same as the key, 0 the level of a random grouping.

GroupingGroupsARI with the answer key
Sales volume grade30.035
Region × sales volume grade120.104
Region70.209
Location50.432
Sales-mix clusters51.000

The two groupings Lumoda has to hand know very little about the customer. The sales volume grade is at the random level, region knows a little, and the grid of the two is worse even than region. Location knows a lot outside the metros and nothing inside them. The sales-mix clusters are the key itself.

There is a limit to trusting this table: part of it comes from the way the data was built. I will say so separately in the honesty list below.

Without a referee: no key

In a real chain there is no answer key. What you are left with is the clusters’ own properties. In this series we used three. The silhouette says how well separated the clusters are. Stability, how well the split holds when some of the stores are missing. Year-to-year agreement, how much the clusters built with the data of two different years resemble each other.

All three are reasonable measures. The problem is that they do not agree:

GroupingMeasureThe grouping’s valueThe recommendation’s valueARI with the answer key
Mix, size and season; 3 clustersstability0.9920.8510.055
Sales volume gradeyear-to-year agreement0.8340.6420.035
Mix and scale; 3 clusterssilhouette0.3510.3080.138

The recommendation is the five clusters we built from the sales mix. Its agreement with the answer key is 1.000. But each of the three groupings in the table beats it on one referee-free measure; and all three are far from the key. Someone looking at stability would have picked the three-cluster split that also takes in size and season; in the fourth article the code’s first draft did exactly that. Someone looking at year-to-year agreement would have stayed with the sales volume grade. Someone adding scale to the mix and looking at the silhouette would have picked a split that resembles the volume grade.

“Then which one do I look at?” says Pelin.

“Write down which one you’ll look at before you see the result,” says Pars. “We said silhouette, with stability on a tie. But writing it down isn’t the end of it. None of the referee-free measures tells you whether the cluster is any use. Only the decision you make by the cluster tells you that.”

Decision quality: in Initial Allocation

The third way is the most laborious: is a decision made by cluster better than one made without clusters? In a real chain this is not easy to measure either, but it is the real question.

We measured it in the game season of the Initial Allocation series. In the last article we built the cluster share: a new product’s share in a store is the relative rate of the store’s cluster on similar products, times the store’s scale. We ran this share with five groupings and raced it against Initial Allocation’s arms. One of the groupings is Lumoda’s own groups: the 12 cells of the region × sales volume grade grid. All the arms send the same stock; only the stock is split across the stores by different shares.

The Lumoda arm in Initial Allocation is not a grouping: it is Lumoda’s published plan, store by store; in the table it is called Lumoda’s store plan.

The measures are Initial Allocation’s. Availability: on what percentage of the days with demand for a size in a physical store was that size on the rail. Leftover: the stock left in the chain as the season closes, as a percentage of the stock that came into the chain. Share error: how far the share given strays from the share that comes out of the first six weeks’ real demand; 0 is perfect. Gross profit: what is left of net sales once the purchase cost is taken off.

ShareAvailabilityLeftoverShare errorGross profit
Lumoda’s store plan68.98%19.77%0.235TRY 534,433,105
Cluster: Lumoda’s groups (region × turnover)69.35%20.08%0.238TRY 533,564,172
Cluster: sales volume grade69.19%20.44%0.241TRY 531,930,817
Cluster: region69.35%19.74%0.236TRY 532,789,729
Cluster: sales mix (machine learning)69.53%19.65%0.230TRY 534,816,112
Cluster: answer key (hidden profile)69.51%19.55%0.231TRY 534,298,578
The store’s past share69.51%19.65%0.229TRY 535,147,736
Model (LightGBM)70.41%17.74%0.171TRY 550,029,513

Let us read the table with four questions.

Are the sales-mix clusters better than Lumoda’s groups? This is the series’ real question: what if we had planned with the sales-mix clusters instead of Pelin’s grid? Yes, a little, and on all four measures. On the published stream they are 0.2 points ahead on availability; leftover is 0.43 points and share error 0.008 lower; gross profit is TRY 1,251,940 higher. This is not the result of a single stream: on all five of the five customer streams we will see below, the sales-mix clusters are ahead of Lumoda’s groups on availability, leftover and share error.

Against Lumoda’s store plan? The share by sales-mix cluster is 0.6 points ahead of the store plan on availability; its leftover and share error are lower than the store plan’s too. The share by Lumoda’s groups is 0.4 points ahead of the store plan on availability, but TRY 868,933 behind on gross profit; its leftover is 0.31 points and its share error 0.003 higher. The share by sales volume grade is hardly different from the store plan: 0.2 points ahead on availability, but behind on leftover, share error and gross profit. Its gross profit gap is TRY 2,502,288. The share by region is 0.4 points ahead on availability.

Better than the store’s own history? No; level. On availability 69.53% against 69.51%, a difference of 0.0 points to one decimal. Leftover is the same. Share error is 0.001 higher with the cluster share, and gross profit TRY 331,624 lower. The cluster share adds nothing to the store’s own past share.

Better than the model? No. The LightGBM model that forecasts store by store is 0.9 points ahead on availability. Share error 0.171 against 0.230.

Even the perfect cluster

The answer key row in the table is the clusters built from the key. In real life there can be no such arm; it is here for one question only: what would happen if the grouping were perfect?

Nothing: the availability difference from the sales-mix clusters is 0.0 points. Here I need to be honest: in this data this comparison is almost empty. On the 67 stores the sales-mix clusters are already exactly the key. The two arms’ clusters differ in only one store: Izmir 2. The five neighbours had put it in the metro young cluster; the key puts it in the Anatolian family cluster. Calibration also chose different settings for the two arms, both the starting level and the threshold: in the game season the answer key arm steps down to category for every product. So this row does not really answer the question “what if the cluster were better”; the clusters are almost the same already.

What is really interesting is the other end of the table. With the sales volume grade clusters, whose agreement with the answer key is 0.035, availability is 69.19%. With the sales-mix clusters, whose agreement is 1.000, it is 69.53%. The grouping goes from the random level to perfect; availability goes only from 69.19% to 69.53%.

“So the grouping I choose changes availability this little?” says Pelin.

“Against the store’s own past share it gains nothing,” says Pars. “At its very best the cluster share only catches up with it. I think the reason is this: each of these 67 stores has at least half a year of sales. What the cluster knows, what the store sells, the store’s own history knows too. The cluster share cannot find a better history than the store’s own; it reads the same information from a group.”

In the last article we saw one more thing. We had hoped that pooling in a cluster would make usable the fine similarity that drowns in noise at store level. Calibration did not support that: with few examples the fine level came out noisy at cluster level too, and a high sample threshold was chosen.

Does it hold on other customer streams?

All of this comes from a single customer stream. As in Initial Allocation, there are four more streams in the same world. We reran the sales-mix clusters, Lumoda’s groups and the answer key arm on every path. The clusters were also rebuilt on every path from that path’s own tables; on every path five clusters of the same sizes came out (33 / 14 / 8 / 7 / 7), and Lumoda’s grid gave the same 12 groups on every path. We ran the sales volume grade and region only on the published customer stream; they are not on the paths.

On availability, five paths:

ComparisonPaths aheadMedian gap across paths
Sales-mix cluster − Lumoda’s store plan5/5+0.6 points
Sales-mix cluster − Lumoda’s groups5/5+0.2 points
Lumoda’s groups − Lumoda’s store plan5/5+0.4 points
Sales-mix cluster − the store’s past share3/50.0 points
Sales-mix cluster − model0/5−0.9 points
Answer key − sales-mix cluster2/50.0 points

The answer to the series’ real question is the same on the paths. The sales-mix clusters are ahead of Lumoda’s groups on all five of the five paths: on availability, leftover and share error. The availability gap is small, between 0.1 and 0.4 points from path to path, but on no path does it change direction. Lumoda’s groups also beat the store plan on availability on all five of the five paths, but on leftover on only one path, and on share error on none.

Against Lumoda’s store plan the result is solid too: the sales-mix clusters are ahead on all five of the five paths on availability, and on leftover and share error as well. The tie with the store’s past share is solid as well. The cluster share is ahead on three of the five paths, but on those paths the gap is close to zero, 0.0 to one decimal; on the other two it is 0.3 points behind. On share error it is better than the past share on none of the five paths. The answer key arm is ahead on two paths, but there too the gap is close to zero. The model is ahead on all five of the five paths.

The cluster’s place

So is the cluster of no use? As far as we measured in this data, put in place of Lumoda’s groups it improves the initial allocation’s share a little; on top of the store’s own past share it adds nothing. But that is not the cluster’s only job.

For a store with no history of its own, the cluster share puts the history of similar stores in place of that history. Izmir 2 and Kocaeli 1 took their shares from the cluster: their mix from their cluster, their size from their cluster’s middle store. The store’s past share arm counted them as average stores. We did not measure these two stores’ own results separately; they are two stores among 69.

The plan, the assortment and markdowns are built group by group too. In the second article we said the cluster is the unit of four decisions. In this series we measured only one, the initial allocation’s share. We did not rebuild Pelin’s category plan by cluster; nor did we touch the assortment or markdowns.

Where do these measurements fall short?

The honesty list, all in one place.

The answer key is not real. I gave every store its customer profile. In real life there is no such referee. All the refereed numbers can be set up only at Lumoda; in your chain you will have the referee-free measures and decision quality.

In the data’s storyline, location largely decides the customer. I wrote the location rule’s city → climate table by hand from general geography; it matches the climate labels of the simulator that generates Lumoda in 24 of 25 cities. The synthetic chain was built on top of real geography. Location’s success outside the metros comes partly from that.

Some choices were settled after seeing results. The choice rule for the recommended clustering was written before the results, but the code’s first draft had another form, and the rule went back to its written form after the answer key’s result was seen. When choosing the feature weighting we also saw one result from the key while exploring. For the new store, the five neighbours method was preferred to the nearest centroid after the results were seen; the measure needed no referee, but the choice was made by looking at the result. I wrote all three down in their place.

The assortment is fixed. At Lumoda which store carries which product is set up in the world from the start and does not change in this series. The trace the assortment leaves on the sales mix turned out small in this data; there is no guarantee it will be small in your chain. We did not apply the cluster to the assortment decision either.

We did not measure customer data. In this synthetic data the customer’s age is derived almost directly from the store’s hidden profile; making customer data a feature would hand the answer key back to the clustering. In a real chain it may be a strong signal; this series did not measure it.

The perfect cluster arm measures almost nothing. Because the sales-mix clusters are already the same as the key, the two arms’ clusters differ only in Izmir 2.

Only the initial allocation’s share. We did not measure the cluster’s effect on the plan, assortment and markdown decisions. Nor did we measure the new stores’ own results separately.

One chain, one decision day. We built the clusters with a single chain’s data, on one season’s decision day. We rebuilt them for calibration on the previous season’s decision day, and on the paths from each path’s tables; but we did not measure how the clusters live across seasons, or how much the plan changes when they are rebuilt every season. As in Initial Allocation, the paths change only the customer stream.

Turn the dial yourself

The dial below brings two things together: the feature set and the number of clusters. There are three feature sets: the sales mix alone; the mix, the size curve and seasonality; and the same adjusted for assortment. The number of clusters runs from four to eight. The method is k-means. Every number comes from the calculations in the case’s report; when the page opens they are all ready, and nothing is calculated in the browser.

The dial shows four measures: agreement with the answer key (agreement with the referee, ARI), stability, the store count of the smallest cluster, and the silhouette. The first needs the referee; the others do not.

Feature set
Number of clusters
Agreement with the referee, ARI
0.948
Stability
0.923
Smallest cluster
7
Silhouette
0.275
Agreement with the referee, ARI
1.000
Stability
0.851
Smallest cluster
7
Silhouette
0.308
Agreement with the referee, ARI
0.734
Stability
0.791
Smallest cluster
7
Silhouette
0.267
Agreement with the referee, ARI
0.580
Stability
0.850
Smallest cluster
7
Silhouette
0.267
Agreement with the referee, ARI
0.534
Stability
0.874
Smallest cluster
6
Silhouette
0.267
Agreement with the referee, ARI
0.022
Stability
0.988
Smallest cluster
5
Silhouette
0.257
Agreement with the referee, ARI
0.137
Stability
0.986
Smallest cluster
5
Silhouette
0.277
Agreement with the referee, ARI
0.143
Stability
0.963
Smallest cluster
1
Silhouette
0.281
Agreement with the referee, ARI
0.133
Stability
0.901
Smallest cluster
1
Silhouette
0.291
Agreement with the referee, ARI
0.191
Stability
0.772
Smallest cluster
1
Silhouette
0.256
Agreement with the referee, ARI
0.022
Stability
0.970
Smallest cluster
5
Silhouette
0.251
Agreement with the referee, ARI
0.137
Stability
0.995
Smallest cluster
5
Silhouette
0.272
Agreement with the referee, ARI
0.201
Stability
0.896
Smallest cluster
5
Silhouette
0.253
Agreement with the referee, ARI
0.195
Stability
0.868
Smallest cluster
2
Silhouette
0.270
Agreement with the referee, ARI
0.214
Stability
0.766
Smallest cluster
2
Silhouette
0.255

Every combination came with the page; nothing is fetched from a server.

While you play with the dial, watch this. On the sales mix, five clusters are perfect: referee agreement 1.000, silhouette 0.308. At four clusters the agreement drops to 0.948, but stability rises from 0.851 to 0.923. Stability likes the wrong split more. Add size and season, and at four and five clusters stability is almost 1: 0.986 at five clusters. But the referee agreement is 0.137. And at six clusters and above the smallest cluster comes down to a single store. The version adjusted for assortment lands in the same place at five clusters: stability 0.995, agreement 0.137. Stable but wrong.

The question we started with

Istanbul 13 and Istanbul 10 were in the same cell: both in Istanbul, both grade C, both in Marmara × C. In Pelin’s grid the two would have got the same mix. The sales mix showed that Istanbul 13 resembles Eskisehir 2; Ali’s store was selling like Veli’s stores.

Six articles on, this is what we have. The sales volume grade knows nothing about the customer, but it hardly changes from year to year. Region knows a little. Location knows a lot outside the metros and nothing inside them. The sales mix sees both sides, but built on a single year’s sales it moves. Putting a new store in the right cluster without seeing a sale is easy outside the metros and a coin toss inside them. The referee-free measures do not agree. In the initial allocation, the share by sales-mix cluster is a little better than both Lumoda’s groups and the store plan; but it does not beat the store’s own history.

This is not the result I expected. Measuring the cluster by looking at the cluster itself was easy: silhouette, stability, the answer key. Measure it by the decision, and the picture changed. The right cluster shows the customer; but in a store with a history of its own it does not seem to tell the initial allocation’s share any more than that history knows. To a store with no history it gives a share from its lookalikes instead of its own history; we did not measure what that gains, and for Izmir 2 the cluster was wrong. Nor can you know that a clustering is good without measuring the decision you make by it. That was the real job of this series. 🙂

By Sabri Suyunu