Sub topic 4
Rule-based, clustered and predicted segments
This chapter assumes you know basic marketing terms (campaigns, channels, conversion), can read simple tables of customer data, and can follow short Python. It compares the three ways to build a segment and helps you choose between them.
What a segment is
A segment is a group of customers who share something useful for a decision. The decision might be which email to send or which offer to show. The three approaches below differ in who defines the group and what it is based on.
The three approaches
Rule-based segments use conditions a person writes. For example, "bought in the last 30 days and spent over 100". They are easy to explain and audit. They only capture patterns someone already thought of, and thresholds go stale.
Clustered segments are found by an algorithm that groups customers with similar behaviour. You don't supply labels. You choose the features and the number of groups, then read the results and name them. They can reveal groups nobody expected, but the groups are descriptive. A cluster says who is similar. It does not say who will respond.
Predicted segments come from a model trained on a known outcome, such as "purchased in the next 30 days" or "cancelled". Each customer gets a score, and you cut the score into segments, such as the top 10% by churn risk. They aim at a business result, but they need historical outcome data and ongoing monitoring.
| Approach | Defined by | Needs | Main strength | Main weakness |
|---|---|---|---|---|
| Rule-based | A person's conditions | Clear business logic | Transparent and fast | Misses hidden patterns |
| Clustered | Similarity in features | Good features, no labels | Finds unexpected groups | Groups need interpretation |
| Predicted | A model score for an outcome | Labelled history | Targets a result | Harder to explain and maintain |
A small clustering example
This code scales recency, frequency and monetary value, then groups customers with k-means. Scaling matters because k-means uses distance. Without it, the monetary column would dominate the other two.
import pandas as pd
from sklearn.cluster import KMeans
from sklearn.preprocessing import StandardScaler
customers = pd.DataFrame({
"customer_id": [1, 2, 3, 4, 5, 6],
"recency_days": [3, 5, 40, 60, 2, 90],
"frequency": [12, 9, 3, 2, 15, 1],
"monetary": [540.0, 410.0, 120.0, 80.0, 700.0, 25.0],
})
features = customers[["recency_days", "frequency", "monetary"]]
scaled = StandardScaler().fit_transform(features)
model = KMeans(n_clusters=2, n_init=10, random_state=42)
customers["segment"] = model.fit_predict(scaled)
print(customers.groupby("segment")[["recency_days", "frequency", "monetary"]].mean())The output gives the average of each feature per cluster. One cluster will have low recency, high frequency and high spend. You might call it "active high spenders". The other has the opposite profile, so you might call it "lapsed". The algorithm only returns the numbers 0 and 1, and the names are your interpretation.
How the approaches fit together
In practice you combine them. A common pattern is to cluster to discover groups, turn the clearest findings into rules that are easy to run and explain, and use a predicted score to decide who within a group gets a costly offer.
Common errors
- Skipping feature scaling before k-means, so one large-valued column decides the groups.
- Treating cluster numbers as stable. With a different random seed or new data, cluster 0 can become cluster 1.
- Using a cluster as if it predicted behaviour, when it only describes similarity.
- Training a predictive model on outcomes that already depend on past targeting, which bakes in old decisions.
- Choosing the number of clusters by habit instead of checking that each group is distinct and large enough to act on.
Exercise
A retailer wants to send a win-back offer only to customers likely to stop buying in the next 60 days. They have three years of purchase history showing who stopped. Which approach fits best, and why is clustering a weaker choice here?
Show answer
A predicted segment fits best. The retailer has a labelled outcome (who stopped buying), so a model can score each customer's churn risk directly. Clustering only groups customers by similarity and has no link to the outcome, so a cluster may mix customers who will leave with customers who will stay.