E-Commerce RFM Customer Segmentation Engine in Python
Segment your e-commerce customers into VIPs, Promising, and At-Risk tiers using automated RFM analysis on your order exports.
Problem it addresses
Develop a pure Python RFM customer segmentation tool (rfm_engine.py): 1) Parses e-commerce order CSV exports (Customer ID, Order Date, Order Value), 2) Computes Recency, Frequency, and Monetary quintiles (1-5), 3) Assigns actionable customer segment labels (Champions, Loyal Customers, Potential Loyalists, At-Risk, Hibernating, Lost), 4) Outputs segmented CSVs and visual HTML summary charts.
Who it is for
PRO operating in high-growth e-commerce, digital publishing, and direct-response marketing across Saudi Arabia, UAE, and Egypt.
What is inside
Key files listed in the README repository architecture:
examples/salla_orders_sample.csvLICENSEplaybooks/rfm-campaign-playbook.mdplaybooks/segment-retention-playbook.mdREADME.mdreports/rfm_segment_summary.htmlreports/rfm_segments_summary.htmlsample_data/orders_sample.csvsrc/rfm_calculator.pysrc/rfm_engine.pytests/test_rfm.py
How to evaluate and use it
- Read the README first and confirm that the documented problem matches your use case.
- Inspect the listed files to find the data, tools, templates, and tests relevant to your task.
- Follow the repository’s Quick Start and check prerequisites before running commands.
- Compare outputs with documented examples and review limitations before using them in a decision or client workflow.
Quick Start from the README: python -m unittest discover -s tests · python src/rfm_calculator.py --help
Scope and limitations
- Recency, Frequency, Monetary Quantiles: Computes quintile scores (1-5) across transactional order histories to classify customers into actionable lifecycle cohorts.
- Cohort Definitions: Maps numerical scores into 11 standard segments (Champions, Loyal Customers, Potential Loyalists, At Risk, Hibernating, Lost).
- Currency & Timeframe Normalization: Adjusts monetary scoring for local currencies and enforces trailing 365-day rolling analysis windows.
This page summarizes the available documentation; it does not establish performance or business results. Verify data and prerequisites before use.