Data Science · Customer Analytics

Early Warning Model for High-Value Customer Drop-Off

RFM profiling plus clustering (KMeans++, BisectingKMeans, GMM) on the Online Retail dataset isolates 776 high-value customers, and a Random Forest flags drop-off risk with 0.788 ROC-AUC.

Course research in Data Science. Cleans 541,909 transactions into a 4,338-customer RFM matrix, segments customers with unsupervised clustering compared across three algorithms, then builds a supervised early-warning classifier on month-over-month RFM decay to flag high-value customers at risk of churn.

4,338
customers
776
high-value segment
1,917
early-warning signals
0.788
ROC-AUC

[ 01 ]

Research Overview

Losing high-value customers is disproportionately costly — retaining them depends on spotting the decay before they leave.

This project converts raw transactional data into an RFM (Recency, Frequency, Monetary) view, segments customers into value tiers via clustering, and trains a supervised classifier that raises an early-warning flag when a high-value customer's engagement starts dropping.

[ 02 ]

Problem Statement

  • Churn is only obvious after it happens — reactive retention campaigns arrive too late.
  • High-value customers are a minority, so generic churn models either over-alert or ignore the segment that matters most.
  • Raw transaction logs are too granular for modeling and must be aggregated into customer-level behaviour first.

[ 03 ]

Objective

  • Build a clean RFM dataset from the Online Retail corpus (541,909 transactions).
  • Segment customers with clustering and compare KMeans++, BisectingKMeans, and Gaussian Mixture Models.
  • Define and engineer an early-risk label from month-over-month RFM decay for high-value customers.
  • Train a classifier that predicts drop-off risk early enough to act.

[ 04 ]

Methodology

  • Data cleaning: cancelled invoices, invalid transactions, and rows without a customer ID are removed — 541,909 rows reduce to 397,884.
  • RFM engineering: Recency, Frequency, and Monetary computed per customer, then log-scaled with log1p to tame heavy tails.
  • Clustering comparison: KMeans++, BisectingKMeans, and GMM over k=2..7 scored with Silhouette and Davies-Bouldin; k=3 is fixed for stable, interpretable High / Mid / Low segments.
  • Early-risk engineering: RFM rolled up per customer-month, month-over-month drop signals counted (1,917 total), and a high-value customer is labeled at risk when signals accumulate.
  • Classification: a Random Forest (300 trees, max_depth=8, class_weight=balanced) trained on the 776 high-value customers with log-scaled RFM features and the early-risk label.

[ 05 ]

Models Used

KMeans++ / BisectingKMeans / GMM

Clustering candidates over k=2..7, scored by Silhouette and Davies-Bouldin; k=3 chosen for stability.

Random Forest

Supervised early-risk classifier (n_estimators=300, max_depth=8, class_weight=balanced) over log-scaled RFM features.

[ 06 ]

Dataset

  • Online Retail dataset (UCI): 541,909 transactions across 4,338 customers from 2010-12-01 to 2011-12-09.
  • Cleaned to 397,884 rows and aggregated into a per-customer RFM matrix, then into a customer-month panel for signal counting.

[ 07 ]

Implementation

  • Data cleaning, RFM aggregation, and monthly rollups in Python with pandas and NumPy.
  • Clustering evaluated on Silhouette + Davies-Bouldin across models and k values; KMeans++ with k=3 retained.
  • Early-risk labels built from 1,917 month-over-month decay signals across the customer-month panel.
  • Random Forest evaluated on a stratified 25% holdout with a confusion matrix, classification report, ROC curve, and feature-importance bar chart.

[ 08 ]

Key Features

  • log1p-scaled RFM features for robust distance-based clustering.
  • Three-algorithm clustering comparison with two internal-validity metrics.
  • Interpretable value segments — High 17.89% / Mid 39.10% / Low 43.02% of customers.
  • Early-warning signal counting across customer-months that turns raw decay into a supervised label.

[ 09 ]

Results

  • The high-value segment averages 17 days since the last order, 13.3 orders, and ~7,866 in monetary value versus 168 days and 1.3 orders for low-value customers.
  • 70.9% of high-value customers carry a positive early-risk label, underlining how quickly engagement decays without intervention.
  • Frequency decay is by far the strongest risk signal (importance 0.51), ahead of monetary (0.28) and recency (0.20); the raw cluster label adds nothing on top.

[ 10 ]

Outcome

  • A repeatable early-warning workflow that can run on any transaction history to prioritize retention outreach.
  • Segmentation alone yields an immediate, interpretable view of where customer value concentrates.

[ 11 ]

Tools & Technologies

PythonpandasNumPyscikit-learnseabornmatplotlib

[ 12 ]

Challenges

  • Raw retail data is noisy — cancelled invoices, missing customer IDs, and returns require careful cleaning.
  • RFM values are heavily skewed, so naive scaling distorts clustering.
  • Early-risk labels are derived and imbalanced, which caps the classifier's ceiling.

[ 13 ]

Future Improvements

  • Add customer tenure, product-category diversity, and seasonality features.
  • Test gradient-boosting classifiers (CatBoost / XGBoost) and time-to-event (survival) models.
  • Validate the early-warning signals against actual churn in a longitudinal holdout.

[ 14 ]

Related work

Back to research