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.

Project Assistant

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 dimensionSource columnDirection
RecencyRecencylower is better
FrequencyTotal_Purchaseshigher is better
MonetaryTotal_Spenthigher 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:

  1. The three dimensions live on wildly different scales (days vs. dollars vs. counts), so joint clustering would require careful normalization.
  2. 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_Score and Monetary_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 rangeSegment
0Inactive
1–2Occasional
3–4Moderate
5–6Loyal
7–9Premium

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.

Premium

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

SegmentCustomersShareAvg RFMAvg Recency (days)Avg FrequencyAvg MonetaryAvg APVResponse Rate
Inactive9,8740.99%0.0857.5$172$25.2810.1%
Occasional192,74519.27%1.77211.6$451$47.2713.7%
Moderate477,78547.78%3.55315.1$666$51.9814.9%
Loyal284,62028.46%5.33018.1$854$53.2415.8%
Premium34,9763.5%7.21622.4$1138$54.2817.2%

Look up an individual customer

Search the original 2,237-customer dataset and see one customer's full RFM profile.

Open Customer Lookup →