7 Segmentation, Look-alikes, and Basket Analysis
Segmentation groups customers for a decision. A mathematically neat cluster is not useful unless it is stable, reachable, interpretable, and associated with a different action.
7.1 Design a segment around use
Start with:
- the action that may differ by segment;
- the population and scoring date;
- features available before the action;
- minimum segment size and operational constraints; and
- a test of whether segment-specific treatment improves outcomes.
Avoid features that leak future behavior. Spending after a campaign cannot be used to define the audience for that campaign.
7.2 K-means illustration
K-means is sensitive to scale, outliers, initialization, and the chosen number of clusters. The synthetic example standardizes continuous features and uses multiple starts.
set.seed(17)
n <- 180
customers <- data.frame(
recency_days = c(rpois(60, 12), rpois(60, 48), rpois(60, 95)),
orders_12m = c(rpois(60, 9), rpois(60, 5), rpois(60, 2)),
margin_12m = c(
rgamma(60, 8, scale = 30),
rgamma(60, 5, scale = 24),
rgamma(60, 2, scale = 18)
)
)
features <- scale(customers)
segments <- kmeans(features, centers = 3, nstart = 40)
customers$segment <- factor(segments$cluster)
aggregate(
customers[c("recency_days", "orders_12m", "margin_12m")],
by = list(segment = customers$segment),
FUN = mean
)## segment recency_days orders_12m margin_12m
## 1 1 95.01667 2.0500 35.99104
## 2 2 12.97500 10.1500 271.92843
## 3 3 38.95000 5.5375 136.92881
## [1] 60 40 80
Cluster labels such as “high value” are analyst interpretations, not model facts. Refit on resamples or later periods to test stability. Compare clustering with simpler business rules; simplicity may win when performance is similar.
7.3 Look-alike audiences
A look-alike model predicts similarity to a seed audience. The workflow is:
- define an eligible population and a seed tied to the business objective;
- set a feature cutoff before the outcome window;
- create positive and comparison examples without leakage;
- train and calibrate a ranking model;
- evaluate precision, recall, lift, calibration, reach, and stability; and
- run a randomized campaign test on the resulting audience.
The seed determines the model’s meaning. A seed of purchasers may reproduce historical channel access, geography, or socioeconomic patterns. Audit feature provenance, proxy discrimination, consent, and exclusion rules.
Propensity is not uplift. A high-propensity user is likely to convert; an uplift model seeks users whose outcome is most likely to change because of the treatment.
7.4 Market basket analysis
For items \(A\) and \(B\):
\[ support(A \rightarrow B) = P(A \cap B) \]
\[ confidence(A \rightarrow B) = P(B \mid A) \]
\[ lift(A \rightarrow B) = \frac{P(B \mid A)}{P(B)} \]
Lift above one indicates positive association relative to the base rate. It does not prove that promoting item \(A\) will cause purchases of item \(B\).
n_transactions <- 1000
n_a <- 240
n_b <- 300
n_both <- 105
support <- n_both / n_transactions
confidence <- n_both / n_a
lift <- confidence / (n_b / n_transactions)
c(support = support, confidence = confidence, lift = lift)## support confidence lift
## 0.105000 0.437500 1.458333
Filter rules by minimum support, evaluate them on later data, and check margin, inventory, and operational feasibility. Many rules are redundant or driven by promotions and product popularity.
7.5 Conquesting and cannibalization
Conquesting targets customers who may be considering a competitor. Measure incremental acquisition and profit rather than clicks on competitor terms. Respect trademark, platform, privacy, and legal constraints.
Cannibalization occurs when a new product, channel, or promotion shifts demand away from an existing offering. Compare total portfolio contribution, not only sales of the new product. Useful designs include randomized market tests, phased launches, matched controls, and difference-in-differences when their assumptions are credible.