RFM customer segmentation in SQL or pandas with a plan per segment

par fidji ChatGPT Anglais ~574 tokens
Extrait public Verrouillé
Refunds and test orders excluded, a fixed analysis date, quintiles with a fallback when frequency is tied, NTILE SQL + pandas qcut code, 8 to 11 named segments (Champions, At risk, Can't lose them…), an action plan per segment and a holdout to prove impact…

À propos de ce prompt

Builds an RFM (recency, frequency, monetary) segmentation from your transaction table: clean-up rules, scoring that copes with the classic problem of most customers having only one order, SQL and pandas code, a named segment map, and a marketing plan per segment with what not to do. Ends with how to measure campaign impact with a holdout group.

Exemple de résultat

Fourni par l'auteur
STEP 2 — Frequency problem If more than 40% of customers have exactly 1 order, NTILE puts identical customers in different F scores. Use the business bins instead: F1 = 1 order, F2 = 2, F3 = 3–4, F4 = 5–9, F5 = 10+. STEP 3 — SQL (PostgreSQL) ```sql WITH base AS ( SELECT customer_id, DATE '2025-10-31' - MAX(order_date)::date AS recency_days, COUNT(DISTINCT order_id) AS frequency, SUM(net_amount) AS monetary FROM orders WHERE status = 'paid' AND order_date > DATE '2025-10-31' - INTERVAL '24 months' GROUP BY customer_id ) SELECT *, 6 - NTILE(5) OVER (ORDER BY recency_days) AS r_score, … ``` STEP 5 — Action plan | Segment | Rule | Objective | Channel | Offer | Do not | | Can't lose them | R ≤ 2, F ≥ 4 | Win back high-value lapsed buyers | Personal email from founder | Strong | Send the generic newsletter | | Champions | R = 5, F ≥ 4 | Referrals, early access | Email | None | Discount them | …

Fiche technique

Modèle
ChatGPT
Langue du prompt
Anglais
Pour qui
E-commerce managers, CRM and retention marketers, and analysts in retail or DTC brands
Longueur
~574 tokens (estimation)
Format livré
Texte du prompt, affiché en ligne après achat

Avis

Réservés aux acheteurs

Aucun avis pour l'instant. Seuls les acheteurs de ce prompt peuvent en laisser un.

Signaler ce prompt