Scalable Fair Clustering
Arturs Backurs, Piotr Indyk, Krzysztof Onak, Baruch Schieber, Ali Vakilian, Tal Wagner
Introduction
The success of machine learning led to its widespread adoption in many aspects of our daily lives. Automatic prediction and forecasting methods are now used to approve mortgage applications or estimate the likelihood of recidivism (Chouldechova, 2017). It is thus crucial to design machine learning algorithms that are fair, i.e., do not suffer from bias against or towards particular population groups. An extensive amount of research over the last few years has focused on two key questions: how to formalize the notion of fairness in the context of common machine learning tasks, and how to design efficient algorithms that conform to those formalizations. See e.g., the survey by Chouldechova and Roth (2018) for an overview.
In this paper we focus on the second aspect. Specifically, we consider the problem of fair clustering and propose efficient algorithms for solving this problem. Fair clustering, introduced in (Chierichetti et al., 2017), generalizes the standard notion of clustering by imposing a constraint that all clusters must be balanced with respect to specific sensitive attributes, such as gender or religion. In the simplest formulation, each input point is augmented with one of two colors (say, red and blue), and the goal is to cluster the data while ensuring that, in each cluster, the fraction of points with the less frequent color is bounded from below by some parameter strictly greater than . Chierichetti et al. proposed polynomial time approximation algorithms for fair variants of classic clustering methods, such as -center (minimize the maximum distance between points and their cluster centers) and -median (minimize the average distance between points and their cluster centers). To this end, they introduced the notion of fairlet decomposition: a partitioning of the input pointset into small subsets, called fairlets, such that a good balanced clustering can be obtained by merging fairlets into clusters. Unfortunately, their algorithm for computing a fairlet decomposition has running time that is at least quadratic in the number of the input points. As a result, the algorithm is applicable only to relatively small data sets.
In this paper we address this drawback and propose an algorithm for computing fairlet decompositions with running time that is near-linear in the data size. We focus on the -median formulation, as -center clustering is known to be sensitive to outliers. Our algorithms apply to the typical case where the set of input points lie in a -dimensional space, and the distance is induced by the Euclidean norm.E.g., all data sets used to evaluate the algorithms in (Chierichetti et al., 2017) fall into this category.
The running time can be reduced further by applying dimensionality reduction techniques, see, e.g., (Cohen et al., 2015; Makarychev et al., 2018) and the references therein.
We complement our theoretical analysis with empirical evaluation. Our experiments show that the quality of the clustering obtained by our algorithm is comparable to that of Chierichetti et al. (2017). At the same time, the empirical runtime of our algorithm scales almost linearly in the number of points, making it applicable to massive data sets (see Figure 2).
Since the original paper of Chierichetti et al. (2017), there has been several followup works studying fair clustering. In particular, Rösner and Schmidt (2018) and Bercea et al. (2018) studied the fair variant of -center clustering (as opposed to -median in our case). Furthermore, the latter paper presented a “bi-criteria” approximation algorithm for -median and -means under a somewhat different notion of fairness. However, their solution relies on a linear program that is a relaxation of an integer linear program with at least variables, one for every pair of points. Thus, their algorithm does not scale well with the input size. Another algorithm proposed in Bera et al. (2019), requires solving a linear program with variables. Due to the special structure of the LP it is plausible that it can be solved efficiently, but we are not aware of any empirical evaluation of this approach.
The work most relevant to our paper is a recent manuscript by Schmidt et al. (2018), which proposed efficient streaming algorithms for fair -means (which is similar to -median studied here). Specifically, they give a near-linear time streaming algorithm for computing a core-set: a small subset such that solving fair clustering over yields an approximate solution for the original point-set . In order to compute the final clustering, however, they still need to apply a fair clustering algorithm to the core-set. Thus, our approach is complementary to the core-set approach, and the two can be combined to yield algorithms which are both fast and space-efficientWe note, however, that since core-sets typically require assigning weights to data points, such combination requires extending the clustering algorithm to weighted pointsets. In this paper we do not consider the weighted case..
We note that the above algorithms guarantee constant approximation factors, as opposed to the logarithmic factor in our paper. As we show in the experimental section, this does not seem to affect the empirical quality of solutions produced by our algorithm. Still, designing a constant factor algorithm with a near-linear running time is an interesting open problem.
Possible settings of (r,b)𝑟𝑏(r,b).
Chierichetti et al. (2017) gave -fairlet decomposition algorithms only for . This does not allow for computing a full decomposition of the pointset into well-balanced fairlets if the numbers of red and blue points are close but not equal (for instance, if their ratio is 9:10). One way to address this could be to downsample the larger set in order to make them have the same cardinality and then compute a -fairlet decomposition. The advantage of our approach is that we do not disregard any, even random, part of the input. This may potentially lead to much better solutions, partially by allowing that the clusters are not ideally balanced. The general settings of and are also considered by Bercea et al. (2018); Bera et al. (2019).
Our techniques.
Our main contribution is to design a nearly-linear time algorithm for -fairlet decomposition for any integer values of . Our algorithm has two steps. First, it embeds the input points into a tree metric called HST (intuitively, this is done by computing a quadtree decomposition of the point set, and then using the distances in the quadtree). In the second step it solves the fairlet decomposition problem with respect to the new distance function induced by HST. The distortion of the embedding into the HST accounts for the factor in the approximation guarantee.
Once we have the HST representation of the pointset, the high-level goal is to construct “local” -fairlets with respect to the tree. To this end, the algorithm scans the tree in a top-down order. In each node of the tree, it greedily partitions the points into fairlets so that the number of fairlets whose points belong to subtrees rooted at different children of is minimized. In particular, we prove that minimizing the number of such fairlets (which we refer to as the Minimum Heavy Point problem) leads to an -approximate -fairlet decomposition with respect to the distance over the tree.
Preliminaries
for all and , ,
.
A tree rooted at vertex is a hierarchically well-separated tree (-HST) if all edges of have non-negative weights and the following two conditions hold:
The (weighted) distances from any node to all its children are the same.
For each node , the distance of to its children is at most times the distance of to its parent.
High-level Description of Our Algorithm
Our algorithm for -fair -median problem in Euclidean space follows the high-level approach of Chierichetti et al. (2017): it first computes an approximately optimal -fairlet decomposition for the input point set (see Algorithm 1). Then, in the second phase, it clusters the ()-fairlets produced in the first phase into clusters (see Algorithm 2). Our main contribution is designing a scalable algorithm for the first phase of this approach, namely ()-fairlet decomposition.
An important step in our algorithm is to embed the input pointset into a -HST (see Section 2 for more details on HST metrics). To this end, we exploit the following standard construction of -HST using randomly shifted grids.
Note that the final tree generated by the above construction is a -HST: on each path from the root to a leaf, the length of consecutive edges decrease exponentially (by a factor of ) and the distance from any node to all of its children are the same. Moreover, we assume that .
Phase 1: computing (r,b𝑟𝑏r,b)-fairlet decomposition.
Step 1.
Compute an approximately minimum number of points that are required to be removed from the children of so that (1) the set of points contained by each child becomes -balanced, and (2) the union of the set of removed points is also -balanced. More formally, we solve Question 3.2 approximately (recall that for each child , and respectively denotes the number of red and blue points in ).
A point is heavy with respect to if it belongs to a fairlet such that . For each fairlet , denotes the least common ancestor (lca) of the points contained in in .
Suppose that is a node in . For each corresponding to non-empty children of , let be respectively the number of red and blue points that are removed from . The goal is to minimize such that the following conditions hold:
for each , is ()-balanced.
is ()-balanced.
Step 2.
After computing , for each , remove an arbitrary set of red and blue points from and add them to . Then, output an arbitrary -fairlet decomposition of points which is guaranteed to be -balanced by Step 1.
Step 3.
For each non-empty child of , (for ), run which is guaranteed to be -balanced by Step 1.
Here is the main guarantee of our approach in the first step (i.e., ()-fairlet decomposition).
Phase 2: merging (r,b𝑟𝑏r,b)-fairlets into k𝑘k clusters.
In this phase, we essentially follow the same approach as Chierichetti et al. (2017).
Suppose that is an -approximate -fairlet decomposition of . Then, ClusterFairlet() returns an -approximate -fair -median clustering of where denotes the approximation guarantee of the -median algorithm invoked in ClusterFairlet.
Finally, Theorem 3.3 and 3.4 together imply Theorem 1.1.
Fairlet Decomposition: a Top-down Approach on γ𝛾\gamma-HST
In this section, we provide a complete description of the first phase in our -fair -median algorithm (described in Section 3), namely our scalable ()-fairlet decomposition algorithm.
Thus, by Theorem 4.1 and the bound on the expected distortion of embeddings into HST metrics (Theorem 2.3), we can prove Theorem 3.3.
Theorem 3.3. We first embed the points into an -HST and then perform the algorithm guaranteed in Theorem 4.1. By Theorem 2.3, the expected distortion of our embedding to is and by Theorem 4.1, there exists an algorithm that computes an -approximate fairlet-decomposition of with respect to distances in . Hence, the overall algorithm achieves -approximation.
Since the embedding can be constructed in time and the fairlet-decomposition algorithm of Theorem 4.1 runs in near-linear time, the overall algorithm also runs in .
In the rest of this section we prove the following result which together with Claim 4.2 imply Theorem 4.1.
For any tree with the root vertex , the number of heavy points with respect to in the ()-fairlet decomposition constructed by is at most times the minimum number of heavy points in any valid ()-fairlet decomposition of .
In this section, we show that MinHeavyPoints algorithm invoked by FairletDecomposition finds an -approximate solution of Minimum Heavy Points problem.
The high-level overview of MinHeavyPoints is as follows. For any subset of points , we can compute in what the maximal size -balanced subset of is: w.l.o.g. suppose that and . If , the collection is -balanced. Otherwise, it suffices to greedily pick maximal size -fairlets (see procedure UnbalancedPoints for the formal algorithm). This simple observation implies a lower bound on the size of any optimal solution of Heavy Points Minimization with respect to and we use this value to bound the approximation guarantee of MinHeavyPoints algorithm.
UnbalancedPoints() correctly computes the minimum number of points that is required to be removed from so that the remaining points become -balanced. Moreover, the solution returned by the procedure only removes points form a single color class.
Another structure we will refer to in the rest of this section is saturated ()-fairlets. A fairlet is a saturated -fairlet if it has exactly points; points from color and points from color .
Stage 2: Adding free points.
If the “must-have” heavy points are not -balanced, then one color is dominant. For a color class , a collection of points is -dominant if . Moreover, the collection is minimally-balanced -dominant if is -balanced but it will be no longer -balanced even if we remove a single point of color .
Let be the dominant color in the heavy points. Then, we inspect all children of and if there exits a child in which is dominant, we borrow as many points of color as we can (we need to keep the subtree -balanced, see ExtraPoint procedure) till either the set of heavy points becomes -balanced or all subtrees rooted at children of become minimally-balanced -dominant. It is straightforward to show that at most points of color will be borrowed from the children of in this phase.
Suppose that the set of heavy points is -dominant. If the set of heavy points is not -balanced at the end of stage 2, then for each , the set of points in the subtree rooted at is minimally-balanced -dominant.
Suppose that the set of heavy points is -dominant. If the set of heavy points is not -balanced at the end of stage 2, then for each , the set of points in the subtree rooted at have an -fairlet decomposition with at most one non-saturated -fairlet.
Stage 3: Non-saturated fairlets.
Moreover, in any non-saturated -fairlet, , which implies that . Let denote the set of children of whose non-saturated fairlets are picked. After adding all points in these non-saturated fairlets,
Runtime analysis of MinHeavyPoints.
Here we analyze the runtime of MinHeavyPoints which corresponds to step in FairletDecomposition. Note that stage only requires operations on the number of red and blue points in . Each of stage and stage requires operations on the number of red and blue points in all non-empty children of . Although the number of children of can be as large as , for each node in , MinHeavyPoints performs operations on the number of red and blue points in exactly twice: when it is called on and the parent of . Hence, in total MinHeavyPoints performs time on each node in which in total is .
Experiments
In this section we show the performance of our proposed algorithm for -fair -median problem on three different standard data sets considered in (Chierichetti et al., 2017) which are from UCI Machine Learning Repository (Dheeru and Karra Taniskidou, 2017)https://archive.ics.uci.edu/ml/datasets/diabetes. Furthermore, to exhibit the performance of our algorithms on large and high-dimensional scale datasets, we consider an additional data set.
Bank. The datasethttps://archive.ics.uci.edu/ml/datasets/Bank+Marketing is extracted from marketing campaigns of a Portuguese banking institution (Moro et al., 2014). Among the information about the clients, we selected (“age”, “balance”, “duration-of-account”) as attributes to represent the dimensions of the points in the space. Moreover, we consider “marital-status” as the sensitive information.
Census. The datasethttps://archive.ics.uci.edu/ml/datasets/adult contains the records extracted from 1994 US Census (Kohavi, 1996). We picked attributes (“age” , “fnlwgt”, “education-num”, “capital-gain”, “hours-per-week”) to represent the points in the space. Moreover, we consider “gender” as the sensitive attribute.
Census II. The datasethttps://archive.ics.uci.edu/ml/datasets/US+Census+Data+(1990) contains the records extracted from 1990 US Census. We picked 25 numeric attributes to represent points in the space. Moreover, we consider “gender” as the sensitive attribute.
Results.
Comparing the cost of the solution returned by our fairlet decomposition algorithm with the result of (Chierichetti et al., 2017) (as in Table 1) shows that we achieve empirical improvements on all instances. The main reason is that our algorithm is particularly efficient when the input pointset lies in a low dimensional space which is the case in all three datasets “Diabetes”, “Bank” and “Census”. Moreover, unlike (Chierichetti et al., 2017), for each dataset, we can afford running our algorithm on the whole dataset (see Table 3). Empirically, the running time of our algorithm scales almost linearly in the number points in the input pointset (see Figure 2).
In Figure 2 and both Table 1 and 3, the reported runtime for each sample size is the median runtime of our algorithm on different sample sets from the given pointset each of size .
Acknowledgment
The authors would like to thank Ravi Kumar for many helpful discussions. This project was supported by funds from the MIT-IBM Watson AI Lab, NSF, and Simons Foundation.
References
Appendix A Missing Proofs
Lemma 4.3. The proof is by induction on height of in . The base case is when is a leaf node in and the algorithm trivially finds an optimal solution in this case. Suppose that the induction hypothesis holds for all vertices of at height . Here, we show that the statement holds for the vertices of at height as well.
Hence, by the induction hypothesis, for each ,
Next, we bound the cost of sol by Lemma 4.4 and (4) as follows:
Next, we bound the cost of the fairlet decomposition which is constructed by augmenting the set of fairlets with the set of affected points .
Let denote the set of affected points . We augment the fairlet decomposition in three steps:
In this step, we create as many -balanced fairlets using the affected points only. Note that the contribution of each point involved in such fairlets is where denotes the distance of from the leaves in . Let denote the set of affected points that do not join any fairlets at the end of this step. Note that all points in are of the same color .
Step 2:
Next, we add as many points of as possible to the existing fairlets in while preserving the -balanced property. Now the extra cost incurred by each points of that joins a fairlet in this step is at most . Let be the set of points that do not belong to an fairlets by the end of the second phase. Note that at the end of this step, if is non-empty, then all fairlets are maximally-balanced -dominant (a fairlet is maximally-balanced -dominant if (1) in , the number of points of color are larger than the number of points in color , (2) the set is -balanced, and (3) adding a point of color to makes it unbalanced).
Step 3:
Finally, we show that by mixing the points of at most existing fairlets with the set , we can find an -balanced fairlet decomposition of the involved points and the contribution of each such point to the total cost is at most . Note that since the set of all points we are considering is -balanced, not all of the so far constructed fairlets are saturated (i.e., has size exactly ). In particular, we show that there exists a set of non-saturated fairlets of size at most whose addition to constitutes a -balanced set. For each fairlet ,
where and respectively denotes the set of points of color and in . This implies that after picking at most non-saturated fairlets (i.e., the fairlets in ),
where and respectively denotes the set of points of color and in . Hence, the set of points is -balanced. Moreover, the cost of this step is at most .
Let denote the set of the centers of fairlets in . For a set of points , let denotes an optimal -median clustering of (note that there is not fairness requirement). Since , the optimal -median cost of is smaller than the optimal -median cost of . Since contains at most copies of each point of , by assigning all copies of each point in to the center of in an optimal -median clustering of ,
As ClusterFairlet returns a -approximate -median clustering of , and by (5)-(6), the cost of the clustering constructed by ClusterFairlet is
Since the distance of each point to the center of its cluster in is less than the sum of its distance to the center of its fairlet in and the distance of to its center in , we can bound the cost of in terms of the costs of and as follows: