Data Segmentation: Choose Rules or Clustering for Useful Groups
Choose between explicit rules and clustering, define a unit and time window, and validate whether segments are reproducible and useful. A hypothetical order example shows how to make group membership clear.
Data segmentation divides records into meaningful groups so each group can be understood or treated separately. A strong segmentation does not start by choosing an algorithm. First decide what question or action it should support, what one row represents, and how membership can be reproduced. The CGAP practitioner guide distinguishes rule-based and data-driven approaches and emphasizes reviewing clusters in their business context.
What a segment means
A segment is a subset of records that share a characteristic or behavior relevant to a question. You might group customers by time since their last purchase and order frequency, or products by price and sales frequency. The aim is not to divide a table into ever smaller slices. It is to find differences hidden by an overall average or define groups for which separate analysis or treatment is justified.
People in one segment are not identical in every respect. They are similar enough for the purpose and variables you selected. A label such as “recent repeat customer” summarizes observed order rules; it does not determine a person’s character or future behavior. Differences between segments are descriptive observations. Segment membership itself is not proof of what caused an outcome.
Rules or clustering?
When you can already explain the membership criteria, explicit rules are usually more transparent and easier to operate. When you want to explore patterns across several variables and do not yet know the criteria, clustering can help discover candidate groups. Salesforce’s documentation likewise recommends business rules when criteria are explicit and clustering when groups must be found from similarities across several attributes. The CGAP comparison notes that rules are easier to understand and control, while data-driven methods can expose multidimensional patterns but are more sensitive to data quality and require more expertise.
| Approach | Good fit when | Strength | Watch for |
|---|---|---|---|
| Rule-based | You already have business criteria or need the same groups each week | Easy to explain, audit, and reproduce; membership can be traced | It can encode old assumptions and miss new patterns; cutoffs may be arbitrary |
| Clustering | You want to explore similarities and do not yet have clear membership rules | Can find new combinations across multiple variables | Algorithms can create groups that are not useful; results depend on inputs and distance choices |
If the goal is to predict a known target, that is closer to supervised classification than exploratory segmentation. For example, predicting whether a customer will churn next month from labeled past cases is different from discovering groups based on behavior. If the target outcome is also used as an input, later explanations can become circular.
Define the unit and decision first
Before grouping records, write down:
The decision or question, such as whom to contact differently about a repeat purchase or which product groups to review.
The unit of analysis: customer, account, session, or product. If an order row is treated as a customer row, frequent buyers may be counted many times.
The observation period and as-of date. State the window used for behavior variables and how cancellations or refunds affect totals.
Inclusion and exclusion rules, including how to handle inactive accounts, test records, and incomplete identities.
How success will be judged: whether groups are large enough, meaningfully different, and useful for a distinct action or analysis.
Without these definitions, a group with the same name can change across dates or analysts, making comparisons unreliable. Avoid variables that are unrelated to the purpose or cannot be trusted. Before using sensitive data or its proxies, review access permissions and possible effects on people.
Worked example: rule-based customer groups
This is a hypothetical online shop example to illustrate the method. Assume that only completed orders in the 90 days before a reference date count, and refunded orders are excluded. Apply these rules in order so each customer belongs to exactly one group.
| Order | Group rule | Interpretation and next question |
|---|---|---|
| 1 | No completed order in the 90-day window | Did visits or sign-ups fail to become purchases? Check whether the population is meant to include existing customers only. |
| 2 | Exactly one order | Has a first purchase not been followed by another? Check the purchase date and follow-up time. |
| 3 | At least two orders, with the latest within 30 days of the reference date | Is this a recently active repeat group? Review repeat items or time between orders. |
| 4 | At least two orders, with the latest more than 30 days before the reference date | Was this group active before but quiet recently? Check product cycles and seasonality. |
The order of the rules keeps customers with no orders in the window from also matching a later rule, so the groups do not overlap. If the intended population is all customers, also confirm that the rules cover everyone. The 30-day and 90-day cutoffs are arbitrary teaching choices, not universal recommendations. Set real thresholds based on purchase cycles, decision timing, seasonality, and the period for which data are available.
Design inputs and limits when using clustering
Clustering defines similarity through the input variables and distance measure, then groups records according to that definition. It is more accurate to say that the analyst chooses what similarity means and the algorithm searches for a partition than to say that the data reveal customer types by themselves.
When numeric variables use very different units, a distance-based algorithm may be dominated by a variable with a large numeric range, such as revenue. Record why each variable is included and decide how to handle outliers, missing values, redundant variables, and categories. Scaling can reduce differences in units, but it does not decide whether variables deserve equal influence. Several highly related variables can also make one concept count too heavily in the distance calculation.
The scikit-learn documentation explains that K-means requires a chosen number of clusters, minimizes within-cluster sums of squared distances, and assumes convex, roughly isotropic cluster shapes. Do not label its output a “true type” when the data do not fit those assumptions. Compare cluster sizes, distributions, interpretability, and repeatability across several candidate counts and initializations instead of selecting the count from one score alone.
The silhouette coefficient summarizes how close an observation is to its own cluster and how far it is from the nearest other cluster. A higher value means clearer separation under this metric, not that the segments are useful to a business or stable at another time. The scikit-learn explanation also notes that silhouette can favor convex clusters over density-based ones.
Profile the results and test whether they can be reused
Profile each group by comparing its size and the medians, ranges, and distributions of important inputs with the overall population. An average alone can hide outliers or mixed subgroups. Choose names that summarize the clearest observed differences without making claims about people’s character or value. The CGAP guide cautions that statistical separation alone does not establish validity; groups should be reviewed with people who understand the work, with qualitative checks where useful.
At minimum, ask:
How many records are in each group, and is that enough for the intended action? Tiny groups may reflect chance differences and can increase privacy risks.
Are the groups meaningfully different for the selected inputs and purpose? Simplify the solution if a good metric score has no interpretable difference behind it.
Do similar groups remain when you use another sample, time period, or reasonable feature choices? Do not assume two clusters are the same just because their numeric labels match.
What outcomes are observed in each group, and was an outcome already included as an input? Separating inputs from outcomes reduces circular interpretation.
Does an action actually improve results? Differences between segments do not prove causal effects or campaign effectiveness; evaluate interventions separately, for example with an appropriate experiment.
If clusters feed recurring reports or automation, record the cluster definition, variables, reference period, preprocessing, and algorithm version. Decide how new records will be assigned. Salesforce’s clustering documentation distinguishes reusable trained models from dynamically recalculated unsupervised clustering, where assignments and cluster IDs may change between runs. Those are product-specific workflows, but continuity of definitions and labels needs attention in any tool.
Segments, cohorts, and classification
A cohort is commonly defined by a shared starting condition, such as sign-up or first purchase, and used to compare later behavior over time. A segment divides records by attributes or conditions at an analysis point. Analytics tools may use these terms differently, so check the product’s own definitions. If the main question is how outcomes change over time from a common starting point, start with this cohort analysis guide. If the task is to predict an existing labeled category, classification may be more appropriate than clustering.
More segments do not automatically mean better analysis. Start with a clear decision and unit, then try rules people can understand. Explore clustering when a multivariable pattern could answer an important question that rules miss. Treat the result as reusable only when its interpretability, stability, and usefulness are supported together.