K-Means Clustering on Business Data: Reading Segments That Actually Exist
1D k-means on business metrics: the algorithm, a worked store-revenue example, and the pitfalls — k selection, outlier warping, scaling, and false segments.
"Segment your customers" is advice everyone gives and few people implement, because the tooling assumption is that segmentation requires a data team. It doesn't. For a single numeric business metric — store revenue, order value, session duration — one-dimensional k-means is a 20-line algorithm that produces immediately readable segments. It's built into KPI Master for exactly this reason. Here's how it works and where it goes wrong.
The Algorithm in Four Steps
K-means partitions n values into k clusters by minimizing within-cluster variance. In one dimension the procedure is almost trivially visual:
- Initialize k centroids — a robust choice is evenly spaced percentiles of the data (min, median, max for k=3) rather than random points.
- Assign each value to its nearest centroid.
- Update each centroid to the mean of its assigned values.
- Repeat 2–3 until assignments stop changing (or an iteration cap, typically 50–100, is hit).
In 1D this converges fast and deterministically given a fixed initialization. The output isn't just labels — it's a centroid, a size, and a min/max range per cluster, which is all you need to talk about the segments.
A Worked Example: Ten Stores
Say you have monthly revenue (in thousands) for ten stores: 12, 14, 13, 45, 47, 44, 88, 91, 89, 90. Run 1D k-means with k=3, initialized at 12, 45, 88:
- Cluster 1: centroid ? 13.0 — stores at 12, 13, 14. Three underperformers.
- Cluster 2: centroid ? 45.3 — stores at 44, 45, 47. The healthy middle.
- Cluster 3: centroid ? 89.5 — stores at 88, 89, 90, 91. Four flagships.
This is a toy example, but notice what it gives you that a mean (49.3) and standard deviation (32.1) do not: the mean describes no actual store. The distribution is trimodal, and the business questions follow immediately — what do the three stores at ~13k have in common? Is the gap between 47k and 88k structural (location, size) or fixable? Clustering turns a column of numbers into three concrete populations you can investigate.
Pitfall 1: Choosing k
K-means will happily return k clusters for any k you ask, including values that split noise. The standard heuristic is the elbow method: plot total within-cluster variance against k and look for the bend where adding a cluster stops paying off. In practice, for business segmentation, k=3 is a defensible default — "low / mid / high" maps to how people already reason. Going to k=7 on 200 rows usually produces clusters that differ by less than the noise in the metric.
Pitfall 2: Outliers Warp the Centroids
Cluster centers are means, and means chase outliers. Add one store at 500k to the example above and k-means with k=3 will spend an entire cluster on that single point, squeezing everything else into two clusters. The fix is to run outlier detection first (z-score or IQR fencing), exclude or cap the extremes, and cluster the remainder. Segmentation on raw data with unexamined outliers is segmentation of your data-entry errors.
Pitfall 3: Scaling in Higher Dimensions
In 1D, scaling is a non-issue — distance is just absolute difference. The moment you cluster on two metrics (say, revenue in the tens of thousands and churn rate around 0.05), raw Euclidean distance lets the bigger-magnitude variable dominate completely. Revenue differences of 10,000 dwarf churn differences of 0.02. Always standardize (subtract mean, divide by standard deviation) each dimension first, or your "two-dimensional" clustering is secretly one-dimensional.
Pitfall 4: Treating Clusters as Truth
K-means assumes spherical, similarly-sized clusters and will impose them on data that has no cluster structure at all. A uniform distribution of values from 10 to 100 gets "segmented" into low/mid/high just as readily as a genuinely trimodal one. Before acting on clusters, look at the gaps: real segments have valleys between them. If the cluster boundaries cut through dense regions, the segments are artifacts.
Where It Earns Its Place
Used with these caveats, 1D k-means is the fastest path from a raw metric column to an actionable conversation: which entities are in which band, how big the gaps are, and whether the "average" was hiding a split population. That's the standard we hold automated analytics to — not sophistication for its own sake, but the simplest method that surfaces real structure.