Problem
A grocery delivery service with more than 35,000 SKUs and a four-level category tree needs a finer fifth level. The groups feed recommendations, pricing and assortment management, which more than 30 people handle. Category managers build such groups by hand, so the tree depends on personal expertise, shifts when a new manager arrives, and cannot be refreshed on a schedule. Attribute-based grouping fails too: attributes are typed in by many people and differ between categories.
Example from the article: the "Chicken eggs" category has to be split into buckets of interchangeable items, for example by egg grade and pack size.
Solution in brief
Compute a substitutability ("analogy") score for every pair of SKUs from receipts alone: two products are analogs when they share complements but rarely appear in the same receipt. Run hierarchical clustering on these scores for each fourth-level category and cut each dendrogram at a threshold chosen with the help of category managers.
Questions this case answers
- How to group items into small sets of interchangeable alternatives using only co-purchase history, when item attributes are entered by hand and are unreliable
- How to choose a clustering cut-off per group when distance scales differ between groups and no ground-truth partition exists
- How to group thousands of SKUs into small buckets of interchangeable products without relying on manual attributes or category managers' judgment?
- How to measure how substitutable two products are using only receipt (basket) history?
Tools and methods
- Complementarity and analogy scores — pairwise substitutability from the product-receipt graph
- Hierarchical clustering with a dendrogram (SciPy, Plotly) — a customer-decision-tree-like hierarchy per category
- Louvain community detection (NetworkX) — tried as an alternative, not adopted
- scikit-learn metrics and DecisionTreeClassifier — candidate ways to pick the threshold
- SciPy sparse matrices — storage of the mostly empty analogy matrix
Google or a one-time email code. No password.
