Data Science · Unsupervised Learning · Customer Analytics · 2026

RFM Based Customer Segmentation with Online Retail II Data

Customer segmentation on the Online Retail II dataset using an RFM approach. Five clustering algorithms were compared objectively through internal validation, not chosen manually. The final result splits customers into two main segments.

RFM-based customer segmentation diagram
  • 5,878Customers analyzedOnline Retail II data
  • 5 algorithmsModels comparedK-Means through DBSCAN
  • 4 metricsInternal validationCombined ranking without ground-truth labels
  • 2 segmentsFinal resultActive high-value and less-active low-value customers
Case study contents
Case study reading progress

Objective

Group customers based on their purchasing patterns without any ground truth labels, then select the best clustering algorithm objectively using internal validation.

Results and limitations

Out of 5,878 customers, K-Means with two clusters was selected as the best result based on combined ranking across four validation metrics. The first segment represents active, high value customers, the second represents less active, low value customers. Limitation, the dataset has no ground truth labels so external validation like accuracy cannot be performed, and the clustering result depends heavily on the assumed number of clusters.

Visual evidence

Plot of two RFM customer segments
Two main groups emerge from the RFM pattern.
1 / 3

Technical details

Open implementation details

Role and contribution

Worked on the entire project alone. Cleaned transaction data, built RFM features, ran five clustering algorithms, validated results with internal metrics, and interpreted each segment profile.

Methodology

Merged two years of transaction data, cleaned invalid transactions, and built three RFM features per customer. Determined the optimal number of clusters, then ran five different clustering algorithms. Each algorithm was scored using four internal validation metrics, and the one with the best combined ranking was selected as the final result.

Technologies

  • R
  • K-Means
  • Gaussian Mixture Model
  • Hierarchical Clustering
  • PAM
  • DBSCAN
  • RMarkdown
  • Jupyter Notebook
All projects