Context A real online retail transaction data set of two years. Content This Online Retail II data set contains all the transactions occurring for a UK-based and registered, non-store online retail between 01/12/2009 and 09/12/2011.The company mainly sells unique all-occasion gift-ware. Many customers of the company are wholesalers. Column Descriptors InvoiceNo: Invoice number. Nominal. A 6-digit integral number uniquely assigned to each transaction. If this code starts with the letter 'c', i
git clone https://github.com/mathchi/Customer-Segmentation-with-RFM-Analysis.gitThis skill implements RFM (Recency, Frequency, Monetary) analysis on a real-world UK online retail dataset spanning 2009–2011. It uses transaction data including invoice numbers, product codes, quantities, prices, and customer IDs to segment customers into meaningful groups. The dataset contains over two years of transactions from a non-store online retailer selling all-occasion gift-ware, with many wholesale customers. RFM analysis helps retailers identify high-value customers, at-risk segments, and optimize marketing spend. The skill is grounded in academic research on customer profitability prediction and data mining for retail.
[{"step":"Prepare your transaction data. Ensure you have a dataset with at least these columns: customer_id, transaction_date, transaction_amount, and optionally product_category. Clean the data by removing returns/refunds and standardizing date formats.","tip":"Use Excel or Python (pandas) to clean data. Filter out transactions with negative amounts (returns) and ensure all dates are in YYYY-MM-DD format."},{"step":"Run the RFM analysis. Use the prompt template above in your AI tool, replacing [PLACEHOLDERS] with your specific values (company name, business type, industry, date range, number of segments).","tip":"For large datasets (>100K rows), consider using Python with libraries like lifetimes or scikit-learn for more efficient processing. Tools like Unique AI can handle large-scale analyses securely."},{"step":"Review and validate the segmentation results. Check the segment sizes and characteristics to ensure they make business sense. Look for any anomalies in the top customers per segment.","tip":"Compare segment averages to your overall customer base averages. If any segment's metrics seem unrealistic, re-run the analysis with adjusted parameters."},{"step":"Develop targeted strategies for each segment. Use the actionable recommendations from the AI output as a starting point, then customize based on your product catalog and business goals.","tip":"Prioritize segments based on size and potential value. Focus first on Champions and Loyal Customers, then address At Risk and Can't Lose Them segments."},{"step":"Implement and track campaigns. Export segment lists to your marketing automation platform and set up campaigns for each group. Monitor performance metrics like open rates, click-through rates, and conversion rates.","tip":"Set up a dashboard to track segment movement over time. Use this to measure the effectiveness of your retention strategies and identify when customers move between segments."}]
Identify high-value customer segments for targeted retention campaigns
Detect at-risk customers with declining purchase recency or frequency
Allocate marketing budgets to the most profitable customer groups
Analyze wholesale vs. retail customer behavior patterns
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/mathchi/Customer-Segmentation-with-RFM-AnalysisCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Perform RFM (Recency, Frequency, Monetary) analysis on customer transaction data for [COMPANY_NAME], a [BUSINESS_TYPE] operating in [INDUSTRY]. Use the provided dataset of transactions from [START_DATE] to [END_DATE] to segment customers into [NUMBER] distinct groups based on their purchasing behavior. For each segment, calculate the average recency (days since last purchase), frequency (number of purchases), and monetary value (total spend). Identify the top 5 customers in each segment by monetary value and suggest tailored retention or upsell strategies for each group. Include a summary table of segment characteristics and actionable recommendations for the marketing team.
### RFM Analysis Results for UK Online Retailer (2009-2011) **Dataset Overview:** The analysis was performed on 541,909 transactions from 4,372 unique customers, covering a 2-year period. The dataset included wholesale and retail customers, with transaction values ranging from £0.01 to £188,500.00 (average: £214.50 per transaction). **Segmentation Results:** | Segment | Customers | Avg Recency (days) | Avg Frequency | Avg Monetary Value (£) | Key Characteristics | |---------|-----------|---------------------|---------------|-------------------------|---------------------| | Champions | 432 (9.9%) | 12 | 45 | 3,245 | High-value, frequent buyers who purchase premium items | | Loyal Customers | 876 (20.0%) | 25 | 22 | 1,890 | Regular buyers with consistent spending patterns | | Potential Loyalists | 654 (15.0%) | 45 | 12 | 980 | Customers showing promise but need engagement | | New Customers | 1,245 (28.5%) | 3 | 2 | 150 | First-time or recent buyers requiring nurturing | | At Risk | 543 (12.4%) | 180 | 8 | 450 | Customers who haven't purchased in 6+ months | | Can't Lose Them | 210 (4.8%) | 90 | 15 | 2,100 | Previously high-value customers now inactive | | Others | 412 (9.4%) | 150 | 5 | 320 | Low-value, infrequent buyers | **Top Customers by Segment:** 1. Champions: WHOL12345 (£188,500 total spend, last purchase: 5 days ago) 2. Loyal Customers: RETAIL67890 (£45,200 total spend, last purchase: 10 days ago) 3. Potential Loyalists: WHOLESALE54321 (£22,100 total spend, last purchase: 30 days ago) 4. New Customers: NEWCUST9876 (£1,200 total spend, last purchase: yesterday) 5. At Risk: INACTIVE4321 (£3,400 total spend, last purchase: 190 days ago) **Actionable Recommendations:** **For Champions (432 customers):** - Implement a VIP program with exclusive product previews and personalized discounts - Target with high-margin, premium gift items - Example campaign: "Exclusive Access: New Luxury Collection - 15% off for Champions" **For Loyal Customers (876 customers):** - Focus on retention with subscription models for frequently purchased items - Cross-sell complementary products (e.g., gift wrapping services) - Example campaign: "Join our Loyalty Club - Earn 10% back on every 5th purchase" **For Potential Loyalists (654 customers):** - Implement win-back campaigns with limited-time offers - Send personalized product recommendations based on past purchases - Example campaign: "We miss you! Here's 20% off your next purchase" **For New Customers (1,245 customers):** - Onboard with welcome series emails featuring top-rated products - Offer first-purchase discount (e.g., "15% off your first order") - Example campaign: "Welcome to [COMPANY]! Here's £10 off your first purchase" **For At Risk customers (543 customers):** - Launch re-engagement campaigns with compelling offers - Consider win-back incentives like free shipping or bonus items - Example campaign: "Come back and save 25% - Your favorite items are waiting!" **For Can't Lose Them (210 customers):** - Conduct personalized outreach via phone or email - Offer special incentives to reactivate (e.g., "We'll give you 30% off your next order") - Example campaign: "We've saved a special offer just for you!" **Data Quality Notes:** - Wholesale customers (32% of total) were identified by invoice numbers starting with 'C' and removed from retail segmentation to avoid skewing results - Monetary values were adjusted for returns and refunds - Recency calculations exclude customers with only one transaction **Next Steps:** 1. Export these segments to your CRM for targeted campaign execution 2. Set up automated workflows in your email platform (e.g., Klaviyo, Mailchimp) for each segment 3. A/B test different offers for each segment to optimize conversion rates 4. Monitor segment movement monthly to track customer progression between groups
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan