Customer segmentation through RFM and machine learning

Exploratory analysis and K-means clustering to uncover distinct customer groups from transaction behaviour.

Case Study

Segmentation is one of the most requested and most poorly executed analyses in retail. This piece uses the public UCI Online Retail II dataset, twelve months of transactions from a UK online retailer, to show the full method: RFM feature engineering, cluster selection tested with both elbow and silhouette methods, and segment definitions written so that marketing team can act on them without a data scientist in the room.

The business problem

A UK online retailer facing rising customer acquisition costs and undifferentiated marketing, the same message to every customer, regardless of whether they had bought last week or two years ago. Spend was rising while return on it was not.

Objectives

Our approach

1. RFM feature engineering

Recency, frequency and monetary value derived per customer from twelve months of transaction data.

2. Cluster selection, tested

K-means with the number of clusters selected using both elbow and silhouette methods.

Segment

Share

What it means

Loyal Champions

18%

Recent, frequent, high value. Retention is worth more here than acquisition anywhere else.

Potential loyalists

27%

Promising behaviour, not yet established. The segment where marketing spend has the highest marginal return.

New or low value

19%

Early or small. Worth nurturing cheaply rather than targeting expensively.

At risk or churned

36%

Dormant revenue. The largest group, and the one most retailers continue to pay to reach.

What it means

Revenue concentrates sharply among a small high-value base, the Pareto pattern held clearly in this dataset. More than a third of customers are inactive or at risk of churn, which is dormant revenue rather than lost revenue, and a materially cheaper thing to pursue than new acquisition.

The actionable conclusion is reallocation rather than more spend: the same budget, directed by segment, produces a different return.

A caution worth stating

Segmentation is only as good as the transaction data beneath it. If point-of-sale (POS), online store and accounting system disagree on what a sale is, a segmentation model will produce confident groupings from inconsistent inputs. That is why we assess the data estate before we model it.

If this sounds like your organization

If your POS, your online store and your accounting system each report a different sales figure, segmentation is premature, start by finding out which number is the number.

Analysis performed on the UCI Online Retail II dataset, a public dataset of transactions from a UK-based online retailer.