Data mining · association · RFM

data-mining-retail

A reproducible fictional retail pipeline ranks cross-sell rules by lift and turns Recency, Frequency, and Monetary behavior into explainable segments.

Public · synthetic demo
The problem

Popular items can make weak pairings look strong.

Confidence alone rewards common products. Lift asks whether items co-occur more than chance, while RFM separates valuable but quiet customers from generic top spenders.

Input

A fixed fictional transaction history

3,000 transactions · 300 customers · 16 items
customer_id, transaction_date, item, price
Planted patterns include milk+sugar→coffee
and butter+eggs→bread.
The money shot

Measured associations and actionable customer states

Committed top association rules by lift chart
Rules ranked by excess co-occurrence over chance.
Committed customer segments chart
All 300 fictional customers assigned to one RFM segment.
Antecedent → consequentSupportConfidenceLift
milk + sugar → coffee0.08030.73033.926
butter + eggs → bread0.05800.54212.978
apples + pasta_sauce → pasta0.02830.51202.839
bacon + pasta → pasta_sauce0.02200.79522.764
SegmentCustomersAvg recencyAvg frequencyAvg monetary
Champions563.512.5254.1
At-risk4950.512.7137.6
Lost5279.87.165.1

At-risk customers bought frequently but have gone quiet—the win-back group a top-spender list misses.

How it's verified

Explainable math, not a black box.

Apriori support, confidence, and lift are implemented directly; RFM scores use deterministic quantiles. Tests verify metric math on toy baskets, planted-rule recovery, valid score ranges, complete segmentation, and that Champions are more recent and valuable than Lost.

Honest limitations
  • All transactions, rules, and segments are fictional and illustrate the method.
  • Support and lift thresholds must be tuned to catalogue size and business cost.
  • Large catalogues require lower support carefully and a capped itemset length to control Apriori cost.
  • Association is not causation; test merchandising actions before rollout.