DataLab / Customer Segmentation
Who are your customers, really?
An RFM (Recency, Frequency, Monetary) segmentation pipeline built on the Kaggle “Customer Personality Analysis” dataset — three independent K-Means models, re-ranked into five business-ready personas, then re-scored at production scale through a BigQuery batch pipeline.
Customers scored
1,000,000
Total revenue
$689,568,820
Avg customer value
$689.57
Last campaign response
15.0%
Based on 1,000,000 synthetically-scaled customers, generated to demonstrate the BigQuery batch-scoring pipeline.
Project Chat
Ask this project's own assistant about the methodology, segments, and pipeline — coming soon.
Ask this project's own assistant about the methodology, segments, or pipeline — coming soon.
Methodology
What is RFM?
RFM is a customer-scoring framework used in CRM and marketing to rank customers on three behavioral dimensions:
- Recency — how recently the customer last purchased. Lower is better.
- Frequency — how often they purchase. Higher is better.
- Monetary — how much they spend overall. Higher is better.
Customers with strong scores across all three are your most valuable; weak scores across all three are churn risks. The three-way split also separates customer types that pure revenue ranking would conflate — e.g. a high-spend customer with stale recency behaves very differently from a high-spend customer with recent activity.
How RFM maps to the dataset
| RFM dimension | Source column | Direction |
|---|---|---|
| Recency | Recency | lower is better |
| Frequency | Total_Purchases | higher is better |
| Monetary | Total_Spent | higher is better |
Total_Purchases is the sum of all Num*Purchases channels (deals + web + catalog + store), and Total_Spent is the sum of all Mnt* product categories — both engineered during the cleaning phase.
From clusters to a score
Why K-Means? K-Means is an unsupervised algorithm that partitions data into k groups by minimizing within-cluster variance. It's a natural fit for RFM because each dimension has clear “tiers” of customer behavior that aren't pre-labeled.
Why three 1D models, not one 3D model? This pipeline runs K-Means once per RFM dimension — three separate models on Total_Purchases, Total_Spent, and Recency. This avoids two pitfalls of joint 3D clustering:
- The three dimensions live on wildly different scales (days vs. dollars vs. counts), so joint clustering would require careful normalization.
- Each dimension has its own natural breakpoints — running K-Means independently respects them.
Hyperparameter search. Each 1D model is tuned with RandomizedSearchCV over n_clusters ∈ [2..4], init ∈ {'k-means++', 'random'}, n_init ∈ [10..50], max_iter ∈ [100..700]. The cluster cap of 4 is deliberate: too many clusters per dimension makes the final segments hard to translate into marketing actions. All three searches converged on k = 4.
From cluster label to score. The cluster ID itself is meaningless (K-Means assigns IDs arbitrarily), so each component's clusters are re-ranked by their average value:
Frequency_ScoreandMonetary_Score— clusters sorted ascending by average → scores 0→3.Recency_Score— clusters sorted descending by average → scores 0→3 (recent = high score).
The final RFM score. The three scores sum into a single RMF_Score from 0 to 9, which is bucketed into five business segments:
| Score range | Segment |
|---|---|
| 0 | Inactive |
| 1–2 | Occasional |
| 3–4 | Moderate |
| 5–6 | Loyal |
| 7–9 | Premium |
Worth flagging: the final segments are not K-Means clusters in 3D — they're score-bucket labels. A Premium customer is defined as “RMF_Score ≥ 7,” not “member of cluster X.”
Segment breakdown & 3D view
Each point below is one of the real customers the model was trained on, plotted on the three RFM dimensions. The segment sizes here reflect that original training population — the segment deep-dive further down switches to the scaled BigQuery dataset.
Loading customer data…
Segment deep-dive
From here on, the numbers come from the same model re-scored against a synthetically-generated, 1,000,000-row dataset through the project's BigQuery batch-scoring pipeline — a look at the segmentation running at production scale, not just on the original training sample.
Based on 1,000,000 synthetically-scaled customers, generated to demonstrate the BigQuery batch-scoring pipeline.
Recent, frequent, high-spend customers — your VIPs. Retention and reward programs are the priority.
Customers
34,976
Share of total
3.5%
Avg RFM score
7.16
▲ 3.4 vs. population
Avg total spent
$1137.57
▲ $448.00 vs. population
Avg purchases
22.4
▲ 6.9 vs. population
Avg recency (days)
15.6
▲ 33.6 vs. population
Avg purchase value
$54.28
▲ $3.03 vs. population
Last campaign response
17.2%
▲ 2.2% vs. population
Recommended marketing actions
- VIP perks: early access, exclusive products, dedicated account management
- Loyalty rewards tied to spend tier
- Cross-sell premium product lines
- Personalized concierge campaigns
Compare segments
| Segment | Customers | Share | Avg RFM | Avg Recency (days) | Avg Frequency | Avg Monetary | Avg APV | Response Rate |
|---|---|---|---|---|---|---|---|---|
| Inactive | 9,874 | 0.99% | 0.0 | 85 | 7.5 | $172 | $25.28 | 10.1% |
| Occasional | 192,745 | 19.27% | 1.7 | 72 | 11.6 | $451 | $47.27 | 13.7% |
| Moderate | 477,785 | 47.78% | 3.5 | 53 | 15.1 | $666 | $51.98 | 14.9% |
| Loyal | 284,620 | 28.46% | 5.3 | 30 | 18.1 | $854 | $53.24 | 15.8% |
| Premium | 34,976 | 3.5% | 7.2 | 16 | 22.4 | $1138 | $54.28 | 17.2% |
Look up an individual customer
Search the original 2,237-customer dataset and see one customer's full RFM profile.
Open Customer Lookup →