From when to who and why
Halfway through the track, the artifacts start feeding each other. The cohort table (a2) and viz gallery (a3) answer "are we retaining?" Today's segments answer "retaining whom?" - and the RFM table you build this session becomes the direct input for a6's buy-till-you-die CLV models, while the behavioral-cohort workflow becomes the hypothesis engine for a7's churn features. Everything runs on the repo's synthetic ecommerce orders first, then on Online Retail II. Work along in the companion notebook notebooks/a4_segmentation.ipynb.
RFM: the classic that still ships 15 min live
RFM is direct-marketing technology from Arthur Hughes' 1994 playbook, and it survives because it is honest and cheap: score every customer on Recency (days since last purchase), Frequency (order count), and Monetary (total spend), each cut into quintiles, 5 best. Concatenate the three digits and a 555 is your best customer, a 111 your most gone. Personas make the codes speakable: Champions (555/554), Loyal, At-Risk (155/144 - were frequent and valuable, going quiet), Hibernating. And the same table is the exact input a6's BTYD models want: recency, frequency, and tenure per customer.
Live★ Build-along: R, F, M from raw orders to personas9 min▶
Three prompt-boxes, one pipeline. The snapshot date is fixed and written down - the frozen-history law applies to segments too: an RFM table recomputed against a drifting "today" is a segment view that quietly restates.
Read the At-Risk group first, always: high frequency, low recency means proven customers drifting away - the one segment where a winback message has both a reason and an audience.
Self-studyRFM pitfalls: what bites on real data4 min read▶
- qcut chokes on spiky data. When half your customers have frequency = 1, quintile edges collide and
pd.qcutraises duplicate-bin-edge errors. The fix is in step 2 above: rank first (rank(method="first")), then cut the ranks. You trade exactness of ties for a working pipeline. - Wholesalers land in Champions and eat your averages. The Online Retail II lesson from a2 returns: a handful of trade buyers who order weekly will occupy the top of every quintile and drag every per-segment average toward themselves. Inspect the top of the Champions list by hand before you report it - some of your "best customers" are businesses, not fans.
- The snapshot date must be fixed. Recency computed against a moving "today" makes every customer drift one score-point downward per quiet week, so last month's segment counts are not comparable to this month's. Freeze the snapshot, version the table, and recompute on a declared cadence - frozen history, again.
Freeze the snapshot and recompute on a declared cadence, and the snapshots start talking to each other: crosstab January's personas against July's for the same customers and every move becomes visible. This is the monitoring layer RFM is usually missing - one table that says who upgraded, who went quiet, and where the winback budget should go.
The same July snapshot, promoted to a dashboard row: the value_counts() output with a quarter-over-quarter delta and a revenue bar attached, one tile per persona.
Acquisition tells when, behavior tells why 12 min live
a2's triangle groups users by WHEN they joined - an acquisition cohort - and it is superb at spotting that month 2 is where everyone leaves. It says nothing about why. A behavioral cohort groups by an action taken: used feature X in week 1, made a second purchase within 30 days. Compare the retention curves of the did-it and did-not groups and the dip acquires a suspect. The workflow is always the same pair: the acquisition cohort spots the dip, the behavioral cohort explains it.
Live★ Build-along: one behavioral split, two overlaid curves7 min▶
The ecommerce classic: does a second purchase within 30 days predict long-run retention? Flag each customer, then run a2's recipe once per group and overlay.
The vertical distance between the two lines at month 6 IS the business case for driving second purchases: multiply the gap by cohort size and ARPU and you have the number that gets the email flow funded. The gap sizes the prize; the experiment proves the mechanism.
L28: the power-user curve 10 min live
Take one 28-day window and plot a histogram: how many users were active exactly 1 day, 2 days, up to all 28. Why 28 and not 30? Four exact weeks, so every user sees the same weekday mix - this is the same trick behind games reporting D28, and the fix previewed in a1 for stickiness averages. Invented on Facebook's growth team, popularized through a16z's "power user curve" essay, and the shape is the whole verdict.
Live★ Build-along: the L28 histogram and stickiness by persona6 min▶
Then close the loop with Part 1: compute stickiness per RFM persona instead of one blended ratio. One small table replaces a quarter of arguments:
| Persona | What the stickiness row typically shows |
|---|---|
| Champions | Highest by far - the daily-habit end of the histogram lives here |
| Loyal | Healthy, steady - the middle of the smile |
| At-Risk | Falling month over month - the early-warning row |
| Hibernating | Near zero - they are the tall day-1 bar on the left |
One blended DAU/MAU hides all four rows. The segment table is the honest version - and the At-Risk row falling is a churn alarm you get months before it shows in the triangle.
Personas and activity are the same customers seen twice. Map the July snapshot onto the R x F plane and the persona zones from Part 1 light up as density - including the wholesaler dots the pitfalls card warned you about.
Same chart, two industries. For a mobile game, the L28 smile IS the whale pipeline: only 2-5% of players ever pay, and payers emerge from the hardcore daily core on the right of the histogram - retention precedes monetization, so a studio with no smile has no monetization future either. For ecommerce the segmentation punchline is concentration: returning customers are roughly 21% of the customer base but drive about 44% of revenue - which is why the Champions and At-Risk corners of the RFM grid, a quarter of your customers, deserve most of your retention budget.
Try it yourself - this week ◐ 30 min total
- Run the full RFM pipeline on Online Retail II (after a2's clean-up gate). Then inspect the Champions list by hand and count how many are actually wholesalers - report the number, because it will surprise you.
- Build your own product's L28 histogram for one fixed 28-day window and name its shape out loud: smile, slumped-left, or something in between. Add it to your running retention report next to the triangle.
- Pick one behavior you believe drives retention, run the two-curve overlay, and write the one-sentence business case: gap x cohort size x ARPU.
What this session draws on
Segmentation is the oldest craft in retention analytics - RFM predates the web - standardized by a few durable sources. Everything above is the working core of:
Three questions before you go 🎯 ◐ 90 seconds
1 · Why is recency the one RFM dimension scored in reverse?
Frequency and monetary reward big numbers; recency rewards small ones - a customer seen 3 days ago is more alive than one seen 300 days ago. Reversing the labels (labels=[5,4,3,2,1]) keeps all three digits pointing the same way, so 555 reads as best on every axis.
2 · Acquisition cohorts vs behavioral cohorts: which one answers WHY retention dipped?
Acquisition cohorts group by WHEN users joined, so they locate the dip in time. Behavioral cohorts group by WHAT users did, so the curve gap points at a candidate cause - and its size prices the fix. The workflow is always: acquisition spots it, behavioral explains it, an experiment confirms it.
3 · Your L28 histogram is a smile: tall at 1 active day, tall again at 25-28. What does it mean?
The right-hand hump is the point: a real population of users shows up nearly every day. Most products only have the left hump (slumped-left = no core). For a game, that daily core is where the 2-5% of payers come from; for any product it is the segment worth studying, protecting, and growing.