Explainable K-Means

Machine Learning
Introduced by
Dasgupta, S.; Moshkovitz, M.; Frost, N.; Rashtchian, C.
Year
2020
Type
Explainable unsupervised clustering algorithm
Family
Machine learning

What does it do?

Explainable K-Means builds a small axis-aligned decision tree that approximates the partition produced by standard K-Means.

Each leaf corresponds to one cluster, and a point's cluster is determined by a sequence of threshold tests on single features. The method accepts some loss of within-cluster cost in exchange for cluster rules that can be read and communicated directly.

The intuition behind the method

Standard K-Means assigns each point to its nearest centroid, so its boundaries are Voronoi cells that depend on distances to all centroids at once, which is hard to state in words. Explainable K-Means replaces those boundaries with a tree whose tests each involve one feature and one threshold. A cluster can then be described as a conjunction of conditions, such as 'age above a cut-off and spend above a cut-off', instead of 'closest to centroid 3'. The tree's induced clustering cost is generally higher than the K-Means optimum, and the size of that gap is the price of the interpretability.

History

The method was presented in 2020 by Moshkovitz, Dasgupta, Rashtchian, and Frost in the Proceedings of the 37th International Conference on Machine Learning (PMLR 119), under the title 'Explainable k-Means and k-Medians Clustering'. The work treats the replacement of K-Means boundaries by threshold decision trees as an approximation problem with respect to the K-Means cost. The method is also referred to by the alias ExKMC.

When to use it

Choose Explainable K-Means when cluster membership must be stated as rules that non-specialists can check, such as customer segments defined by business thresholds or patient subgroups defined by clinical cut-offs. It fits tabular data with continuous features and a moderate number of clusters. No validated upper bound on k is given on this page, so the depth and rule count of the fitted tree should be checked on the specific dataset. Do not use it when k is large enough that the tree becomes deep and hard to read, when the clusters are elongated, overlapping or non-convex (where density-based or probabilistic methods such as DBSCAN or a Gaussian mixture model are more appropriate), or when maximal clustering quality matters more than readable rules.

Limitations and considerations

  • Axis-aligned splits approximate the oblique boundaries of K-Means. Where the centroids separate along diagonal directions, the tree needs more splits or accepts a higher cost.
  • The gap between the tree's cost and the K-Means cost can widen as k grows or as the data become more complex, because a larger partition generally requires more splits to reproduce.
  • The greedy construction does not guarantee the globally best explainable partition.
  • The tree inherits the assumptions of the reference clustering. If K-Means is a poor fit for the data, for example because clusters are elongated or overlapping, the tree approximates a poor partition.
  • Features must be continuous, because K-Means relies on Euclidean distances. Encoded categorical variables give thresholds whose meaning must be interpreted with care.
  • Outliers can pull centroids, and therefore the reference partition the tree is trying to approximate. Results also depend on the initialisation of the reference K-Means, so several restarts are advisable.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Each cluster is described by a root-to-leaf path of single-feature threshold tests, so the membership rule can be read directly from the tree.
  • Assignment of new points requires only threshold comparisons and no distance calculations against the centroids.
  • The method is applied to an existing K-Means solution, using its centroids as the reference partition, so the upstream clustering pipeline does not need to change.
  • The cited framework frames the loss from interpretability as an approximation problem relative to the K-Means cost, so the size of the loss can be measured and reported.
  • The fitted tree lists which features and thresholds separate the clusters, which gives a concrete basis for auditing the segmentation.

Applications

  • Customer segmentation with membership rules that marketing and CRM teams can read and apply directly.
  • Clinical patient subgroup discovery where clinicians need threshold-based criteria, for example age above 60 combined with HbA1c above 7.
  • Regulated classification settings in which automated groupings must be explained, such as financial risk tiers.
  • Exploratory analysis that inspects which features and thresholds separate the clusters.
  • Compressing a K-Means partition into a small rule set for deployment where computing distances to all centroids is undesirable.

How it works

How it works

1

Standard K-Means, or a K-Means variant, is first run on the dataset to obtain k reference centroids. These centroids define the target partition that the tree tries to approximate. The quality of this reference partition therefore bounds the quality the tree can reach.

2

A threshold decision tree is grown over the feature space to approximate the K-Means partition. Each internal node tests one feature against one threshold, so every split is an axis-aligned cut. The tree has exactly k leaves, one per cluster, because each leaf identifies one cluster of the target partition. The tree is built by a search or a greedy procedure that tries to reduce the gap between its clusters and the reference clusters.

3

At each node, the algorithm chooses the feature and threshold whose cut most reduces the clustering cost, measured as the sum of squared distances from points in that node's region to the region's centroid. A greedy strategy takes the locally best cut at each step and gives no guarantee of the globally best partition. An exact strategy searches over all candidate cuts and is therefore more expensive.

4

The cost of the tree is the total within-cluster sum of squared distances under the partition the tree induces, computed as cost(T) = sum over i of ||x_i - c_l(x_i)||^2. This value is compared with the K-Means optimum, and their ratio, the approximation factor, measures how much clustering quality is lost for the sake of interpretability. Because the K-Means optimum is the smallest such cost over all partitions into k clusters, the tree cost is never below it.

Formula
\text{cost}(T) = \sum_{i} \|x_i - c_{\ell(x_i)}\|^2
5

After the tree is fixed, a point is assigned to a cluster by following the threshold tests from the root to a leaf, and the leaf identifies the cluster. Assignment therefore needs only a few comparisons per point and no distance computation against the centroids.

Common pitfalls

  • Reporting a deep, unreadable tree as explainable. When k is large, the rule set may no longer be usable by the stakeholders it was meant for.
  • Reading the tree's thresholds as causal cut-points rather than descriptive approximations of the cluster geometry.
  • Omitting the comparison between the tree-induced cost and the K-Means cost, which leaves readers unable to judge what the interpretability costs.
  • Applying the method to clusters better described by density or probabilistic models, and then attributing poor segments to the method rather than to the mismatch.
  • Running K-Means on features measured in different units or scales without standardisation. Both the centroids and the axis-aligned thresholds then depend on those units, so the rules may reflect scale rather than structure.

Frequently asked questions

How does Explainable K-Means differ from just running a decision tree on K-Means labels?

A decision tree fitted to K-Means labels is trained to predict those labels as accurately as possible, which does not directly minimise the clustering cost of the partition the tree induces. Explainable K-Means instead targets the within-cluster sum of squares under the tree's partition, and the cited framework analyses that objective with approximation bounds, which a generic classifier does not provide.

How many clusters (k) is too many for the method to remain interpretable?

Interpretability falls as k grows because the tree needs more splits and becomes harder to read. No validated upper bound on k is given on this page, so the practical limit should be checked on the specific dataset by inspecting the tree depth and rule count. For large k, hierarchical clustering, which is listed among the related methods, may give a more suitable structure.

Does the method require rerunning K-Means, or can it work on any existing clustering?

Explainable K-Means uses K-Means centroids as the reference target. It can be applied after an existing K-Means run, so K-Means does not need to be rerun. The centroids are still needed, because they are used to compute the approximation cost.

What is a typical approximation cost ratio, and how large a quality loss is acceptable?

The tree-induced cost is never below the K-Means optimum, because that optimum is the smallest within-cluster cost over all partitions into k clusters. No typical approximation ratio is quoted here, since none has been verified against a primary study, so the ratio of tree cost to K-Means cost should be computed and reported on your own data. Whether the resulting loss is acceptable is an application decision; where transparency is required, a larger cost may be judged worth paying.

Can Explainable K-Means handle categorical features?

The method is designed for continuous features because K-Means relies on Euclidean distances. Categorical features must first be numerically encoded, for example with ordinal encoding or binary indicators, and the resulting threshold rules on encoded values must be interpreted carefully.

Related methods

Sources

  1. Dasgupta, S., Frost, N., Moshkovitz, M., & Rashtchian, C. (2020). Explainability of k-Means Clustering. Proceedings of the 37th International Conference on Machine Learning (ICML), PMLR 119.

    Open publication reference
  2. Moshkovitz, M., Dasgupta, S., Rashtchian, C., & Frost, N. (2020). Explainable k-Means and k-Medians Clustering. Proceedings of the 37th International Conference on Machine Learning (ICML), PMLR 119.

    Open publication reference