UK-registered +44 7367 067226
WhatsApp FOLLOW f in X
  1. Home
  2. Blog
  3. Customer Segmentation With Machine Learning
AI & Machine Learning

Customer Segmentation With Machine Learning

How to build machine learning customer segments your marketing and sales teams will actually act on, from RFM basics to clustering and its pitfalls.

Updated 4 min readBy SpiderHunts Technologies

Free estimateNo obligation

Get a free estimate

Tell us what you need. A senior engineer reads every enquiry.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →

Quick answer: TL;DR

Customer segmentation with machine learning groups customers by behaviour, usually with clustering on features such as purchase frequency, spend, recency, product mix and channel. It works when each segment maps to a different action. Start with RFM scoring, add clustering only when simple rules miss real patterns, and name segments by what you will do with them.

Segments nobody acts on are a slide, not a system

Most businesses that have tried segmentation have a deck somewhere with six personas: Budget Brenda, Loyal Larry and friends. The deck was presented, everyone nodded, and the email platform still sends the same campaign to the whole list.

The problem is rarely the maths. Segments fail because they were built to describe customers rather than to change what the business does for them. Machine learning makes it easier to find groupings in data, and it also makes it easier to find groupings that are statistically tidy and commercially useless.

Start from the decision, not the data

Before touching a model, write down the decisions segments will drive. If you cannot name at least a few different actions, you do not need segmentation yet.

  • Which customers get a win-back offer, and how generous it is
  • Who receives new-range announcements first
  • Which accounts a sales rep calls this month
  • Who is excluded from discount campaigns because they buy at full price anyway
  • Which customers get a premium service tier or account manager

Each decision suggests the features that matter. Win-back is about recency and past value. Discount exclusion is about price sensitivity. That list shapes the model more than any algorithm choice.

RFM first, because it is usually most of the value

Recency, frequency and monetary value is a decades-old technique and still the best starting point. Score each customer on how recently they bought, how often and how much, then group them. It runs in a spreadsheet or a few lines of SQL.

RFM patternTypical labelSensible action
Recent, frequent, high spendBest customersEarly access, no discounts needed
Not recent, previously frequentLapsing loyalPersonal win-back, ask what changed
Recent, first purchaseNewOnboarding sequence, second-purchase nudge
Not recent, low frequency, low spendDormantLow-cost reactivation or suppress
Frequent but low spendRegular small basketsBundles and threshold offers

For many small and mid-sized businesses, RFM segments with clear actions outperform a sophisticated clustering model that nobody understands. We say that often, and it costs us work.

When clustering adds something

Clustering earns its place when behaviour has more dimensions than RFM captures. A wholesaler whose customers differ by product category mix, order channel, seasonality and payment terms may have groups that RFM flattens together.

The usual approach is to engineer features per customer, scale them, and run an algorithm such as k-means, Gaussian mixtures or HDBSCAN. Typical features include:

  • Share of spend by product category
  • Average days between orders and the variability of that gap
  • Average discount taken and share of orders bought on promotion
  • Channel mix: web, phone, rep, marketplace
  • Return rate and support contacts per order
  • Tenure and trend in spend over the last two quarters

An illustrative case: a B2B supplier of catering consumables with 3,000 trading accounts. RFM separates big and small spenders. Clustering on category mix and ordering rhythm finds a group of small cafes that order weekly by phone and a group of contract caterers who order monthly online in bulk. Same spend band, completely different service needs.

The pitfalls that make clusters meaningless

  1. Unscaled features. Total spend in pounds swamps a ratio between zero and one, so the clusters are really just spend bands.
  2. Choosing k by elbow plot alone. The statistically best number of clusters is often not the number your team can act on. Five usable segments beat nine elegant ones.
  3. Unstable clusters. Rerun with a different random seed or a month more data. If customers jump between segments, the structure is weak.
  4. Averages that hide the story. Always look at the distribution within each cluster, not only the centroid.
  5. Mixing one-off and repeat customers. A customer with one order has almost no behaviour to cluster; segment them separately.

Making segments operational

A segment is only real once it lives in the tools people use. That means writing segment membership back to the CRM or email platform on a schedule, not exporting a CSV once.

Refresh monthly for most businesses, weekly for fast-moving retail. Track movement between segments, because customers shifting from best to lapsing is often the most valuable signal in the whole exercise. It sits naturally alongside a churn prediction model if you have one. If you are unsure where the data should live, our guide to customer data platforms covers the options.

Name segments by the action they trigger. Win-back candidates is harder to ignore than Cluster 4.

What it costs and when to skip it

RFM segmentation wired into an email platform is a small project, often a few days. A clustering model with feature engineering, validation and CRM write-back is typically several weeks, most of it on data cleaning and integration rather than the algorithm.

Skip clustering if your customer base is small, say a few hundred accounts, because a sales team usually knows those customers better than any model. Skip it too if marketing can only send one campaign a month; more segments than you can serve is waste. Where it does fit, SpiderHunts treats it as part of broader data science work, with RFM as the baseline every model has to beat.

FAQ

Frequently asked questions

The questions readers ask us after this guide.

Still have a question?

Ask us directly. A senior engineer reads every question.

Ask about your project

What is the best algorithm for customer segmentation?

K-means is a reasonable default for scaled numeric features and is easy to explain. Gaussian mixture models allow softer membership, and HDBSCAN handles irregular shapes and outliers. The features you choose matter far more than the algorithm.

How many customer segments should we have?

As many as you can treat differently, which for most teams is four to seven. If two segments would get the same campaign, merge them.

Can we use AI to write the segment descriptions?

A language model can usefully summarise each cluster's statistics into a readable profile. Check it against the numbers, because models sometimes invent traits that sound plausible but are not in the data.

How often should segments be recalculated?

Monthly suits most B2B and considered-purchase businesses. High-frequency retail may benefit from weekly updates. Keep the segment definitions stable between refreshes so reports remain comparable.

Is RFM still relevant with machine learning available?

Yes. It is transparent, cheap and captures the behaviour that drives most marketing decisions. Use it as the baseline and only adopt clustering when it clearly finds groups RFM misses.

Keep reading

More on AI & Machine Learning

Start here

Have customer data but no segments anyone uses?

Send us an anonymised export and tell us what decisions the segments should drive. We will say whether clustering adds anything over simpler rules.

  1. You tell us what you needTwo minutes on the form, or a message on WhatsApp.
  2. A senior engineer reviews itAnd comes back with questions, a realistic range and an honest view on fit.
  3. Free 30-minute scoping callWe talk through scope, options and a realistic estimate, with no obligation.
Free estimateNo obligation

Talk to someone who builds this

Send a short brief and we will come back with an honest view and a realistic range.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →