Abstract
We show that the popular k-means clustering algorithm (Lloyd's heuristic), used for a variety of scientific data, can result in outcomes that are unfavorable to subgroups of data (e.g., demographic groups). Such biased clusterings can have deleterious implications for human-centric applications such as resource allocation. We present a fair k-means objective and algorithm to choose cluster centers that provide equitable costs for different groups. The algorithm, Fair-Lloyd, is a modification of Lloyd's heuristic for k-means, inheriting its simplicity, efficiency, and stability. In comparison with standard Lloyd's, we find that on benchmark datasets, Fair-Lloyd exhibits unbiased performance by ensuring that all groups have equal costs in the output k-clustering, while incurring a negligible increase in running time, thus making it a viable fair option wherever k-means is currently used.
Introduction
Clustering is a foundational tool for data analysis, used in everything from market segmentation to resource allocation, such as deciding where to place police patrols or health clinics. The most common method, Lloyd’s algorithm for $k$-means, aims to minimize the total average squared distance between data points and their nearest centers. However, this global optimization often overlooks the distribution of costs across different demographic subgroups.
The Fairness Gap in Standard $k$-Means
When data contains demographic subgroups (e.g., based on race, gender, or education), standard $k$-means often produces clusters where one group is much closer to the centers than another. This "fairness gap" is evident in benchmark datasets. For example, on the UCI Adult dataset, standard $k$-means results in an average cost for Asian-Pac-Islanders that is significantly higher than for white individuals.
If a cluster center represents a "service," a group with a higher average distance to that center is effectively receiving a lower quality of service. Prior research on "fair clustering" focused almost exclusively on proportionality—ensuring each cluster has a balanced representation of different groups. This paper argues that proportionality doesn't solve the problem of equitable costs; in fact, forcing proportionality can sometimes increase cost disparity.
Socially Fair $k$-Means and the Fair-Lloyd Algorithm
The authors propose a new objective: Socially Fair $k$-Means. Instead of minimizing the global average cost, the goal is to minimize the maximum average cost across all demographic groups. This ensures that no single group is disproportionately penalized by the clustering outcome.
To solve this, the authors introduce Fair-Lloyd, an adaptation of the classic two-step Lloyd's heuristic:
- Assignment: Assign each point to its nearest center (standard).
- Fair Center Update: Instead of simply averaging all points in a cluster, find new centers that minimize the maximum average cost for the groups within that partition.
Technical Innovations
A key geometric insight is that a "fair" center for a cluster must lie on the line segment (for two groups) or within the convex hull (for multiple groups) connecting the means of the subgroups in that cluster. This discovery turns a potentially complex high-dimensional optimization into a manageable search. For two groups, the center update is reduced to a simple one-dimensional line search. For multiple groups, a Multiplicative Weight Update (MWU) heuristic is employed.
Empirical Evaluation
The algorithm was evaluated on three benchmark datasets: Adult (UCI), Credit (UCI), and Labeled Faces in the Wild (LFW).
- Bias Elimination: In the Adult and Credit datasets, Fair-Lloyd effectively reduced the cost gap to zero. In the LFW dataset, the difference was reduced to less than 1%.
- Minimal "Price of Fairness": Achieving equity came at a low cost. The total $k$-means objective (global average cost) only increased by 0.3% to 4.1% compared to the unfair version.
- Computational Efficiency: The running time overhead was negligible, with Fair-Lloyd being only 4% to 8% slower than standard Lloyd's.
Conclusion
Fair-Lloyd provides a viable, "drop-in" replacement for standard $k$-means in applications where social fairness is a concern. It inherits the stability and efficiency of the original Lloyd's algorithm while ensuring that the benefits of clustering are distributed equitably across all demographic groups.
Summary updated