Why Segmentation Matters
Imagine a company with 100,000 customers.
Should every customer receive the same promotion?
Probably not.
Consider:
- One customer spends $10,000 every year.
- Another spends $20 once and never returns.
Treating them identically wastes money.
Segmentation helps businesses answer:
- Who are our best customers?
- Who is likely to churn?
- Who should receive promotions?
- Who should receive premium service?
- Which customers should we ignore?
Customer segmentation is one of the most common applications of data science.
Learning Objectives
By the end of this lesson, you should be able to:
- Understand customer segmentation
- Perform RFM analysis
- Build customer scores
- Understand behavioral segmentation
- Understand clustering methods
- Apply segmentation to healthcare
- Apply segmentation to supply chains
- Build customer groups using machine learning
What Is Segmentation?
Segmentation means dividing customers into groups that behave similarly.
Instead of:
$$100000\ customers$$
we create smaller groups.
Example:
| Segment | Description |
|---|---|
| VIP | High value |
| Loyal | Frequent buyers |
| At Risk | May leave soon |
| New | Recently acquired |
| Dormant | Inactive |
This allows targeted decision-making.
Why Segmentation Creates Value
Suppose a company has:
$$10000\ customers$$
and sends a $20 coupon to everyone.
Cost:
$$10000\times20=200000$$
Now suppose segmentation identifies:
$$1000$$
high-risk customers.
Coupon cost:
$$1000\times20=20000$$
Same retention effect.
Much lower cost.
The RFM Framework
RFM is one of the oldest and most effective segmentation techniques.
RFM stands for:
- Recency
- Frequency
- Monetary Value
Recency
Recency measures how recently a customer purchased.
Formula:
$$Recency=Current\ Date-Last\ Purchase\ Date$$
Example:
Customer A purchased:
5 days ago
Customer B purchased:
180 days ago
Customer A is generally more valuable.
Why Recency Matters
Most businesses observe:
The more recently a customer purchased, the more likely they are to purchase again.
A customer who purchased yesterday behaves differently from one who has been inactive for a year.
Frequency
Frequency measures how often customers purchase.
Formula:
$$Frequency=Number\ of\ Purchases$$
Example:
Customer A:
$$Frequency=25$$
Customer B:
$$Frequency=2$$
Customer A is typically more engaged.
Monetary Value
Monetary value measures spending.
Formula:
$$Monetary=\sum Purchases$$
Example:
Customer A:
$$Monetary=10000$$
Customer B:
$$Monetary=150$$
Customer A contributes much more revenue.
Example RFM Table
| Customer | Recency | Frequency | Monetary |
|---|---|---|---|
| A | 5 | 20 | 10000 |
| B | 30 | 12 | 4000 |
| C | 120 | 3 | 300 |
| D | 300 | 1 | 50 |
Interpretation:
- A is likely VIP
- B is loyal
- C is declining
- D is dormant
Creating RFM Scores
A common approach is assigning scores from 1–5.
Example:
Recency:
| Days Since Purchase | Score |
|---|---|
| 0–30 | 5 |
| 31–60 | 4 |
| 61–120 | 3 |
| 121–180 | 2 |
| >180 | 1 |
Frequency:
| Purchases | Score |
|---|---|
| Highest 20% | 5 |
| Next 20% | 4 |
| Next 20% | 3 |
| Next 20% | 2 |
| Lowest 20% | 1 |
Monetary is scored similarly.
Combined RFM Score
Suppose:
$$R=5$$
$$F=4$$
$$M=5$$
Combined score:
$$RFM=545$$
or
$$Score=R+F+M=14$$
Higher values indicate more valuable customers.
Typical RFM Segments
| Segment | Example |
|---|---|
| Champions | 555 |
| Loyal Customers | 544 |
| Potential Loyalists | 454 |
| At Risk | 211 |
| Lost Customers | 111 |
Behavioral Segmentation
RFM uses transaction data.
Behavioral segmentation uses customer actions.
Examples:
- Website visits
- App usage
- Search history
- Product views
- Support requests
These often predict future purchases better than historical sales.
Example Behavioral Features
Suppose we track:
- Website visits
- Average session length
- Pages viewed
- Purchases
Customer A:
| Metric | Value |
|---|---|
| Visits | 50 |
| Session Length | 12 min |
| Purchases | 8 |
Customer B:
| Metric | Value |
|---|---|
| Visits | 2 |
| Session Length | 30 sec |
| Purchases | 0 |
Customer A is much more engaged.
Segmentation Using Machine Learning
Instead of manually creating groups, we can let algorithms discover them.
This is called unsupervised learning.
The most common method is:
K-Means Clustering
Intuition Behind K-Means
Suppose each customer has:
$$x=(Recency,Frequency,Monetary)$$
Customers with similar values are grouped together.
The algorithm finds cluster centers:
$$\mu_1,\mu_2,\ldots,\mu_K$$
Each customer is assigned to the nearest center.
K-Means Objective Function
The algorithm minimizes:
$$\sum_{i=1}^{n}\sum_{k=1}^{K}I(z_i=k)|x_i-\mu_k|^2$$
Meaning:
Find groups where customers are as similar as possible.
Example Clusters
Suppose K-Means finds:
Cluster 1
High frequency
High spending
Recent purchases
VIP customers
Cluster 2
Moderate spending
Moderate activity
Regular customers
Cluster 3
Low spending
Long inactivity
Churn risk
Healthcare Example
Suppose a hospital segments patients.
Variables:
- Number of appointments
- Medication adherence
- Chronic disease score
Clusters may reveal:
Segment 1
Highly engaged patients
Segment 2
Moderately engaged patients
Segment 3
High-risk patients needing intervention
Supply Chain Example
Suppose a wholesaler segments retailers.
Variables:
- Annual sales
- Inventory turnover
- Order frequency
Cluster 1:
High-performing retailers
Cluster 2:
Stable retailers
Cluster 3:
Declining retailers
This is very similar to the retailer segmentation work you already perform.
Segment Migration
Customers are not static.
Example:
January:
$$Segment=Champion$$
June:
$$Segment=At\ Risk$$
Data scientists often track movement between segments.
This is called segment migration.
Python Example: RFM Scoring
import pandas as pdrfm = pd.DataFrame({ "Customer":["A","B","C","D"], "Recency":[5,30,120,300], "Frequency":[20,12,3,1], "Monetary":[10000,4000,300,50]})print(rfm)
Output:
Customer Recency Frequency Monetary
0 A 5 20 10000
1 B 30 12 4000
2 C 120 3 300
3 D 300 1 50
Python Example: K-Means Clustering
from sklearn.cluster import KMeansimport pandas as pdX = pd.DataFrame({ "Recency":[5,30,120,300], "Frequency":[20,12,3,1], "Monetary":[10000,4000,300,50]})model = KMeans(n_clusters=3, random_state=42)clusters = model.fit_predict(X)print(clusters)
Complete Business Example
Suppose a retailer has:
$$50000$$
customers.
Segmentation reveals:
| Segment | Customers |
|---|---|
| VIP | 5,000 |
| Loyal | 15,000 |
| Regular | 20,000 |
| At Risk | 7,000 |
| Lost | 3,000 |
Marketing budget:
$$500000$$
Instead of distributing promotions equally, the company can focus on:
- Retaining VIPs
- Re-engaging At Risk customers
- Ignoring Lost customers
This dramatically improves ROI.
Key Takeaways
The core concepts introduced in this lesson are:
$$Recency=Current\ Date-Last\ Purchase\ Date$$
$$Frequency=Number\ of\ Purchases$$
$$Monetary=\sum Purchases$$
$$RFM=(Recency,Frequency,Monetary)$$
Segmentation helps businesses:
- Increase retention
- Improve marketing efficiency
- Reduce churn
- Increase revenue
- Personalize customer experiences
The most common approaches are:
- RFM Analysis
- Behavioral Segmentation
- K-Means Clustering
- Customer Journey Analysis
These techniques form the foundation of customer analytics, retail analytics, healthcare engagement analytics, and supply chain customer management.
Exercises
- Calculate RFM values for five customers using hypothetical purchase histories.
- Design five customer segments for a jewelry retailer.
- Design five customer segments for a hospital.
- Explain why recency is often a stronger predictor than monetary value.
- Fit a K-Means model with:
$$K=3$$
and then:
$$K=5$$
Compare the resulting segments.
References
- Fader, Peter S. Customer Centricity. Wharton Digital Press.
- Gupta, Sunil & Lehmann, Donald. Managing Customers as Investments.
- James, Gareth, Witten, Daniela, Hastie, Trevor, Tibshirani, Robert. An Introduction to Statistical Learning.
- Hastie, Trevor, Tibshirani, Robert, Friedman, Jerome. The Elements of Statistical Learning.
- Han, Jiawei, Kamber, Micheline, Pei, Jian. Data Mining: Concepts and Techniques.
Next Lesson
Lesson 4: Customer Lifetime Value Modeling — From Simple LTV to Probabilistic Models (BG/NBD and Gamma-Gamma Models), where we move from descriptive segmentation into predictive customer valuation.

Leave a Reply