Consistent procedures for cluster tree estimation and pruning
Kamalika Chaudhuri, Sanjoy Dasgupta, Samory Kpotufe, Ulrike von Luxburg
Introduction
Our formalism of the cluster tree (Section 2.2) and our notion of consistency follow early work on clustering, in particular that of Hartigan (1981). Much subsequent work has been devoted to estimating the connected components of a single level set; see, for example, Polonik (1995), Tsybakov (1997) and, more recently, Maier et al. (2009), Rigollet and Vert (2009), Rinaldo and Wasserman (2010), and Singh et al. (2009). In contrast to these results, the present work is concerned with the simultaneous estimation of all level sets of an unknown density: recovering the cluster tree as a whole.
Are there hierarchical clustering algorithms which converge to the cluster tree? Previous theory work (Hartigan, 1981, Penrose, 1995) has provided partial consistency results for the well-known single-linkage clustering algorithm, while other work (Wishart, 1969) has suggested ways to overcome the deficiencies of this algorithm by making it more robust, but without proofs of convergence. In this paper, we propose a novel way to make single-linkage more robust, while retaining most of its elegance and simplicity (see Figure 3). We establish its finite-sample rate of convergence (Theorem 3.3); the centerpiece of our argument is a result on continuum percolation (Theorem 4.7). This also implies consistency in the sense of Hartigan.
We then give an alternative procedure based on the -nearest neighbor graph of the sample (see Figure 4). Such graphs are widely used in machine learning, and interestingly there is still much to understand about their expressiveness. We show that by successively removing points from this graph, we can create a hierarchical clustering that also converges to the cluster tree, at roughly the same rate as the linkage-based scheme (Theorem 3.4).
Next, we use tools from information theory to give a lower bound on the problem of cluster tree estimation (Theorem 6.1), which matches our upper bounds in its dependence on most of the parameters of interest.
The convergence results for our two hierarchical clustering procedures nevertheless leave open the possibility that the trees they produce contain spurious branching. This is a well-studied problem in the cluster tree literature, and we address it with a pruning method (Figure 9) that preserves the consistency properties of the tree estimators while providing finite-sample guarantees on the removal of false clusters (Theorem 7.5). This procedure is based on simple intuition that can carry over to other cluster tree estimators.
Definitions and previous work
We start by considering the more general context of clustering. While clustering procedures abound in statistics and machine learning, it remains largely unclear whether clusters in finite data—for instance, the clusters returned by a particular procedure—reveal anything meaningful about the underlying distribution from which the data is sampled. Understanding what statistical estimation based on a finite data set reveals about the underlying distribution is a central preoccupation of statistics and machine learning; however this kind of analysis has proved elusive in the case of clustering, except perhaps in the case of density-based clustering.
Consider for instance -means, possibly the most popular clustering procedure in use today. If this procedure returns clusters on an -sample from a distribution , what do these clusters reveal about ? Pollard (1981) proved a basic consistency result: if the algorithm always finds the global minimum of the -means cost function (which, incidentally, is NP-hard and thus computationally intractable in general; see Dasgupta and Freund (2009), Theorem 3), then as , the clustering is the globally optimal -means solution for , suitably defined. Even then, it is unclear whether the best -means solution to is an interesting or desirable quantity in settings outside of vector quantization.
Our work, and more generally work on density-based clustering, relies on meaningful formalisms of how a clustering of data generalizes to unambiguous structures of the underlying distribution. The main such formalism is that of the cluster tree.
2 The cluster tree
We start with notions of connectivity. A path in is a continuous function . If and , we write and we say that and are connected in . This relation – “connected in ” – is an equivalence relation that partitions into its connected components. We say is connected if it has a single connected component.
The cluster tree is a hierarchy each of whose levels is a partition of a subset of , which we will occasionally call a subpartition of . Write \Pi({\mathcal{X}})=\{\mbox{subpartitions of{\mathcal{X}}}\}.
Pick any . Then:
3 Notion of convergence and previous work
For each , set to the distance from to its nearest neighbor.
Construct a graph with nodes .
Include edge if .
Hartigan (1981) has shown that single linkage is consistent in one dimension (that is, for ). But he also demonstrates, by a lovely reduction to continuum percolation, that this consistency fails in higher dimension . The problem is the requirement that : by the time the clusters are large enough that one of them contains all of , there is a reasonable chance that this cluster will be so big as to also contain part of .
With this insight, Hartigan defines a weaker notion of fractional consistency, under which (resp, ) need not contain all of (resp, ), but merely a sizeable chunk of it – and ought to be very close (at distance as ) to the remainder. He then shows that single linkage achieves this weaker consistency for any pair for which the ratio
is sufficiently large. More recent work by Penrose (1995) closes the gap and shows fractional consistency whenever this ratio is .
A more robust version of single linkage has been proposed by Wishart (1969): when connecting points at distance from each other, only consider points that have at least neighbors within distance (for some ). Thus initially, when is small, only the regions of highest density are available for linkage, while the rest of the data set is ignored. As gets larger, more and more of the data points become candidates for linkage. This scheme is intuitively sensible, but Wishart does not provide a proof of convergence. Thus it is unclear how to set , for instance.
Several papers (Rigollet and Vert, 2009, Maier et al., 2009, Singh et al., 2009, Rinaldo and Wasserman, 2010) have recently considered the problem of recovering the connected components of for a user-specified : the flat version of our problem. Most similar to the work in this paper is the algorithm of Maier et al. (2009), which uses the -nearest neighbor graph of the data. These level set results invariably require niceness conditions on the specific level set being recovered, often stated in terms of the smoothness of the boundary of clusters , and/or regularity conditions on the density on clusters of the given level set. It is unclear whether these conditions hold for all level sets of a general density, in other words how restrictive these conditions are in the context of recovering the entire cluster tree. In contrast, under mild requirements on the distribution, our conditions on the recovered level sets hold for any level set as the sample size increases. The main distributional requirement for consistency is that of continuity of the density on a compact support .
A related issue that has received quite a lot of attention is that of pruning a cluster tree estimate: removing spurious clusters. A recent result of Rinaldo et al. (2012) gives meaningful statistical guarantees, but is based on the cluster tree of an empirical density estimate, which is algorithmically problematic as discussed earlier. Stuetzle and Nugent (2010) have an appealing top-down scheme for estimating the cluster tree, along with a post-processing step (called runt pruning) that helps identify modes of the distribution. The consistency of this method has not yet been established. We provide a consistent pruning procedure for both our procedures.
The present results are based in part on earlier conference versions, namely Chaudhuri and Dasgupta (2010) and Kpotufe and von Luxburg (2011). The result of Chaudhuri and Dasgupta (2010) analyzes the consistency of the first cluster tree estimator (see next section) but provides no pruning method for the estimator. The result of Kpotufe and von Luxburg (2011) analyzes the second cluster tree estimator and shows how to prune it. However the pruning method is tuned to this second estimator and works only under strict Hölder continuity requirements on the density. The present work first provides a unified analysis of both estimators using techniques developed in Chaudhuri and Dasgupta (2010). Second, building on insight from Kpotufe and von Luxburg (2011), we derive a new pruning method which proveably works for either estimator without Hölder conditions on the distribution. In particular, the pruned version of either cluster tree estimate remains consistent under mild uniform continuity assumptions. The main finite-sample pruning result of Theorem 7.5 requires even milder conditions on the density than required for consistency.
Algorithms and results
The first algorithm we consider in this paper is a generalization of Wishart’s scheme and of single linkage, shown in Figure 3. It has two free parameters: and . For practical reasons, it is of interest to keep these as small as possible. We provide finite-sample convergence rates for all and we can achieve if . Our rates for force to be much larger, exponential in . It is an open problem to determine whether the setting () yields consistency.
Conceptually, the algorithm creates a series of graphs satisfying a nesting property: A point is admitted into only if it has neighbors within distance ; when is small, this picks out the regions of highest density, roughly. The edges of are between all pairs of points within distance of each other.
In practice, the only values of that matter are those corresponding to interpoint distances within the sample, and thus the algorithm is efficient. A further simplification is that the graphs don’t need to be explicitly created. Instead, the clusters can be generated directly using Kruskal’s algorithm, as is done for single linkage.
The second algorithm we study (Figure 4) is based on the -nearest neighbor graph of the samples. There are two natural ways to define this graph, and we will analyze the sparser of the two, the mutual -NN graph, which we shall denote . Our results hold equally for the other variant.
One way to think about the second hierarchical clustering algorithm is that it creates the -nearest neighbor graph on all the data samples, and then generates a hierarchy by removing points from the graph in decreasing order of their -NN radius . The resulting graphs have the same nodes as the corresponding but have potentially fewer edges: . This makes them more challenging to analyze.
The first consideration is that a cluster is hard to identify if it contains a thin “bridge” that would make it look disconnected in a small sample. To control this, we consider a “buffer zone” of width around the clusters.
is a full-dimensional set, even if itself is not.
Second, the ease of distinguishing two clusters and depends inevitably upon the separation between them. To keep things simple, we’ll use the same as a separation parameter.
Under this definition, and must lie within , otherwise the right-hand side of the inequality is zero. need not be contained in .
2 Consistency and rate of convergence
There is an absolute constant such that the following holds. Pick any , and run Algorithm 1 on a sample of size drawn from , with settings
Then there is a mapping such that the following holds with probability at least . Consider any pair of connected subsets such that are -separated for and some . Let . If
Separation. is disconnected from in .
Connectedness. and are each connected in .
The two parts of this theorem – separation and connectedness – are proved in Sections 4.1 and 4.2, respectively.
A similar result holds for Algorithm 2 under stronger requirements on .
Theorem 3.3 applies also to Algorithm 2, provided the following additional condition on is met: where .
In the analysis section, we give a lower bound (Lemma 5.3) that shows why this dependence on is needed.
Finally, we point out that these finite-sample results imply consistency (Definition 2.3): as , take with any schedule of such that and . Under mild uniform continuity conditions, any two connected components of are -separated for some (see appendix); thus they are identified given large enough .
Analysis of Algorithm 1
We also invoke uniform convergence over half-balls: each of these is the intersection of a ball with a halfspace through its center. Using uniform Bernstein-type bounds, we derive basic inequalities which we use repeatedly.
We denote this uniform convergence over balls and half-balls as event .
See appendix. , where is the absolute constant from Lemma C.2. ∎
We will typically preface other results by a statement like “Assume .” It is to be understood that occurs with probability at least over the random sample , where is henceforth fixed. The constant will keep reappearing through the paper.
For any cluster , there is a certain scale at which every data point in appears in . What is this ?
Assume . Pick any set , and let . If and then contains every point in .
Any point has ; and thus, by Lemma 4.1, has at least neighbors within radius . ∎
In order to show that two separate clusters and get distinguished in the cluster tree, we need to exhibit a scale at which every point in and is active, but there is no path from to .
Assume . Suppose sets are -separated by set , and let . Pick such that
contains all points in .
contains no points in .
If , then is disconnected from in .
Part (a) is directly from Lemma 4.2. For (b), any point has ; and thus, by Lemma 4.1, has strictly fewer than neighbors within distance .
For (c), since points in are absent from , any path from to in that graph must have an edge across . But any such edge has length at least and is thus not in . ∎
Define to be the value of for which .
The conditions of Lemma 4.3 are satisfied by if and .
2 Connectedness
We need to show that points in (and similarly ) are connected in . First we state a simple bound (proved in the appendix) that works if and ; later we consider smaller .
Assume . Let be a connected set in with . Suppose . Then is connected in whenever and
Comparing this to the definition of , we see that choosing would entail , which is undesirable. We can get a more reasonable setting of by choosing , but we’d like to be as small as possible. A more refined argument shows that is enough.
Assume . Let be a connected set in with . Suppose . Then is connected in whenever and
Recall that a half-ball is the intersection of an open ball and a halfspace through the center of the ball. Formally, it is defined by a center , a radius , and a unit direction :
We will describe any such set as “the half of in direction ”. If the half-ball lies entirely in , its probability mass is at least . By uniform convergence bounds (Lemma 4.1), if , then every such half-ball within contains at least one data point.
Pick any ; there is a path in with . We’ll identify a sequence of data points , ending in , such that for every , point is active in and . This will confirm that is connected to in .
To begin with, recall that is a continuous function from $Ay\in{\mathcal{X}}N(y)PB(y,r)N(y)=\{0\leq z\leq 1:P(z)\in B(y,r)\}yrPN(y)\pi(y)=P(\sup N(y))ry$ (Figure 5, left).
The sequence is defined iteratively; , and for
If , set and stop.
By construction, is within distance of path and hence .
Let be the open ball of radius around . The half of in direction contains a data point; this is (Figure 5, right).
The process eventually stops since each is further along path than ; formally, . This is because , so by continuity of the function , there are points further along (beyond ) whose distance to is still . Thus is distinct from . Since there are finitely many data points, the process must terminate, so the sequence constitutes a path from to .
Each lies in and is thus active in under event (Lemma 4.2). Finally, the distance between successive points is
where the second-last inequality is from the definition of half-ball. ∎
To complete the proof of Theorem 3.3, take . The relationship that defines (Definition 4.4) then implies
This shows that clusters at density level emerge when the growing radius of the cluster tree algorithm reaches roughly . In order for -separated clusters to be distinguished, the one additional requirement of Lemma 4.3 and Theorem 4.7 is that be at most ; this is what yields the final lower bound on .
Analysis of Algorithm 2
The second cluster tree estimator (Figure 4), based on the -nearest neighbor graph of the data points, satisfies the same guarantees as the first, under a more generous setting of .
Let be the -NN graph at radius . We have already observed that has the same vertices as , and a subset of its edges. Therefore, if clusters are separated in , they are certainly separated in : the separation properties of Lemma 4.3 carry over immediately to the new estimator. What remains is to establish a connectedness property, an analogue of Theorem 4.7, for these potentially much sparser graphs.
We’ll first confirm that is, indeed, a lower bound on the radii .
Assume . If , then for all .
Pick any and consider the ball . By definition of ,
where the last inequality is from the condition on . Under (Lemma 4.1), we then get ; therefore . ∎
Now we present an analogue of Theorem 4.7.
Assume . Let be a connected set in , with . Suppose . Then is connected in whenever and
We’ll consider events at two different scales: a small radius , and the potentially larger radius from the theorem statement.
Let’s start with the small scale. The lower bound on yields
As in Theorem 4.7, this implies that every half-ball of radius within contains at least one data point.
Let and be any two points in . As in Theorem 4.7, we can find a finite sequence of data points such that for each , two key conditions hold: (i) and (ii) lies within distance of .
Now let’s move to a different scale . Since each lies in , we know from Lemma 4.2 that all are active in given the lower bound on . The edges are also present, because
using Lemma 5.1 and the bound on . Hence is connected to in . ∎
It is straightforward to check that is always , and Theorem 3.4 follows immediately.
2 A lower bound on neighborhood cardinality
The result for -nearest neighbor graphs requires a larger setting of than our earlier result; in particular, needs to exceed the ratio . We now show that this isn’t just a looseness in our bound, but in fact a necessary condition for these types of graphs.
Recall that the mutual -NN graph contains all the data points, and puts an edge between points and if (the is our adaptation). We will assume , as is the case in all our upper bounds.
Consider the density shown in Figure 6, consisting of two dense regions, and , bridged by a less dense region . Each region is of width . We’ll show that the mutual -NN graph of a sample from this distribution is likely to be disconnected. Specifically, with probability at least , there will be no edges between and .
To this end, fix any , and define . Consider the leftmost portion of of length . The probability that a random draw from falls in this region is . Therefore, the probability that no point falls in this region is . Call this event .
Next, divide into intervals of length , and so on, starting from the right. We’ll show that with probability at least , the right half of each such interval contains at least points; call this event . To see why, let’s focus on one particular interval, say that of length . The probability that a random point falls in the right half of this interval is . Therefore, the number of points in this region is in expectation, and by a Chernoff bound, is except with probability . Taking a union bound over all the intervals yields an overall failure probability of at most .
With probability at least , events and both occur. Whereupon, for any point in , its nearest neighbor in is at least twice as far as its nearest neighbors in . Thus the mutual -NN graph has no edges between and . ∎
This constraint on is unpleasant, and it would be interesting to either find mild smoothness assumptions on , or better, modified notions of -NN graph, that render it unnecessary.
Lower bound
We have shown that the two cluster tree algorithms distinguish pairs of clusters that are -separated. The number of samples required to capture clusters at density is, by Theorem 3.3,
We’ll now show that this dependence on , , and is optimal. The only room for improvement, therefore, is in constants involving .
Consider any algorithm that is given i.i.d. samples from some and, with probability at least , outputs a tree in which the smallest cluster containing is disjoint from the smallest cluster containing . Then
Given the parameters , we will construct a space and a finite family of densities on . We will then argue that any cluster tree algorithm that is able to distinguish -separated clusters must be able, when given samples from some , to determine the identity of . The sample complexity of this latter task can be lower-bounded using Fano’s inequality (Appendix D): it is , for
where is Kullback-Leibler divergence.
𝑐1𝜎4(c+1)\sigmaaxis A family of densities on . The family contains densities which coincide on most of the support and differ on parts of . Each density is piecewise constant as described below. Items (ii) and (iv) describe the pieces that are common to all densities in .
Density on .
Balls of mass centered at locations along the -axis: each such ball is of radius , and the density on these balls is . We refer to these as mass balls.
Density on the remainder of : this is the union of the cylinder segments and minus the mass balls. Since the cross-sectional area of the cylinder is , the total mass here is at most .
The remaining mass is at least ; we will be careful to choose so that this is nonnegative. The remaining mass is placed on in some fixed manner that does not vary between densities in .
Here is a sketch of . The low-density region of width is centered at on the -axis, and contains no mass balls.
For any , the densities and differ only on the cylindrical sections and , which are disjoint, contain no mass ball, and each have volume . Thus
(using for ). This is an upper bound on the in the Fano bound.
Clusters and separators. Now define the clusters and separators as follows: for each ,
is the tubular segment ,
is the tubular segment , and
is the cross-section of the cylinder at location .
Thus and are -dimensional sets while is a -dimensional set. It can be seen that, for density , and are -separated, and .
Now that the various structures are defined, we still need to argue that if an algorithm is given a sample from some (where is unknown), and is able to separate from , then it can effectively infer the identity of . This has sample complexity .
Let’s set to be a small constant, say . Then, even a small sample of points is likely (with probability at least , say), to contain points from all of the mass balls, each of which has mass . Suppose the algorithm even knows in advance that the underlying density is one of the choices in , and is subsequently able (with probability at least ) to separate from . To do this, it must connect all the points from mass balls within , and all the points from mass balls within , and yet keep these two groups apart. In short, this algorithm must be able to determine (with overall probability at least ) the segment of lower density, and hence the identity of .
We can thus apply Fano’s inequality to conclude that we need
for some absolute constant . The last equality comes from the formula , whereupon .
This is almost the bound in the theorem statement, short a logarithmic term. To finish up, we now switch to a larger value of :
and apply the same construction. We have already established that we need samples, so assume is at least this large. Then, for small enough , it is very likely that when the underlying density is , the sample will contain the four point masses at , , , and . Therefore, the clustering algorithm must connect the point at to that at and the point at to that at , while keeping the two groups apart. Therefore, this algorithm can determine . Applying Fano’s inequality gives , which is the bound in the theorem statement. ∎
Pruning
Hartigan’s notion of consistency (Definition 2.3) requires distinct clusters to be distinguished, but does not guard against fragmentation within a cluster. Consider, for instance, the density shown in Figure 6. Under Hartigan-consistency, in the limit, the cluster tree must include a cluster that contains all of and a separate, disjoint cluster that contains all of . But the tree is allowed to break into further subregions. To be concrete, suppose we draw a sample from that density and receive four points from each of and . Figure 7, left, shows a possible cluster tree on these samples that meets the consistency requirement. However, we’d prefer the one on the right. Formally we want to avoid or remove false clusters as defined below.
Let and be the vertices of two separate connected components (potentially at different levels) in the cluster tree returned by an algorithm. We call and false clusters if they are part of the same connected component of the level set .
This problem is generally addressed in the literature by making assumptions about the size of true clusters. Real clusters are assumed to be large in some sense, for instance in terms of their mass (Maier et al., 2009), or excess massThe excess mass of a component at level is generally defined as . (Stuetzle and Nugent, 2009). However, relying on size can be misleading in practice, as is illustrated in Figure 8. It turns out that, building on the results of the previous sections, there is a simple way to treat spurious clusters independent of their size.
The above intuition is likely to extend to cluster tree procedures other than the ones discussed here. The main requirement on the cluster tree estimate is that points in (as discussed above) be connected at some nearby level in the tree.
2 Separation
Assume . Consider two sets , and let . Suppose there exists a separator set such that
Any path in from to intersects .
3 Connectedness
We now turn to the main result of this section, namely that the pruning procedure reconnects incorrectly fragmented clusters. Recall the intuition detailed above. We first have to argue that points with similar density make their first appearance at nearby levels of the empirical tree. From the analysis of the previous sections, we know that a point is present at level , roughly speaking. We now need to show that it cannot appear at a level too much smaller than this.
These assertions about single points are true only if the density doesn’t vary too dramatically in their vicinity. In what follows, we will quantify the smoothness at scale by the constant
Assume . Pick any and let . Suppose
Then , implying . Using the first inequality and Lemma 4.1, we have , that is . ∎
Next, by combining the above lower-bound on with our previous results on connectedness for both types of algorithms, we obtain the following pruning guarantees.
Let be any connected component of . We’ll show that is connected in (or ) after pruning, from which the lemma follows immediately.
Define . Recall from Definition 4.4 that is the value of for which . The first condition in the lemma statement thus implies that . The second condition, together with Theorem 4.7 or Theorem 5.2, implies that is connected at level of or .
The separation and connectedness results of this section can now be combined into the following theorem.
Then the following holds with probability at least . Define
or in the case of Algorithm 2, the maximum of this quantity and , where .
Recovery of true clusters: Consider any two sets , and suppose . Suppose there exists a set such that
Any path in from to intersects .
Final remarks
Both cluster tree algorithms are variations on standard estimators, but carefully control the neighborhood size and make use of a novel parameter to allow more edges at every scale . The analysis relies on being at least , and on being at least . Is it possible to dispense with (that is, to use ) while maintaining this setting of ?
There remains a discrepancy of between the upper and lower bounds on the sample complexity of building a hierarchical clustering that distinguishes all -separated clusters. Can this gap be closed, and if so, what is needed, a better analysis or a better algorithm?
Appendix A Plug-in estimation of the cluster tree
The problem, however, is that computing the level sets of is usually not an easy task. Hence we adopt a different approach in this paper.
Appendix B Consistency
The following is a straightforward exercise in analysis.
Let be the connected components of , with and .
First, each is closed and thus compact. To see this, pick any . There must be some on the shortest path from to with (otherwise ). By continuity of , there is some ball on which ; thus this ball doesn’t touch . Then doesn’t touch .
Let , and define to be the set of points at distance exactly from : separates from . Moreover, it is closed by continuity of , and hence is compact. Define . Since is compact, (restricted to ) is maximized at some . Then .
To finish up, set . By uniform continuity of , there is some such that doesn’t change by more than on balls of radius . Then for and for .
Thus is a -separator for . ∎
Appendix C Proof details
We start with a standard generalization result due to Vapnik and Chervonenkis; the following version is a paraphrase of Theorem 5.1 of Bousquet et al. (2004).
where .
By applying this bound to the class of indicator functions over balls (or half-balls), we get the following:
The bound from Theorem C.1 yields For the second bound, we use . It follows that
For the last bound, we rearrange to get
Lemma 4.1 now follows immediately, by taking . Since the uniform convergence bounds have error bars of magnitude , it doesn’t make sense, when using them, to take any smaller than this.
C.2 Proof of Lemma 4.6
Consider any . Since is connected, there is a path in with . Fix any . Because the density of is lower bounded away from zero, it follows by a volume and packing-covering argument that , and thus , can be covered by a finite number of balls of diameter . Thus we can choose finitely many points such that , and
Under (Lemma 4.1), any ball centered in with radius contains at least one data point if
Assume for the moment that this holds. Then, every ball contains at least one point; call it .
By the upper bound on , each such lies in ; therefore, by Lemma 4.1, the are all active in . Moreover, consecutive points are close together:
Thus all edges exist in , whereby is connected to in .
All this assumes that equation (C.1) holds for some . Taking gives the lemma.
Appendix D Fano’s inequality
Player is given i.i.d. samples from .
Dasgupta is grateful to the National Science Foundation for support under grant IIS-0347646, and von Luxburg acknowledges funding of the German Research Foundation (individual grant LU1718/1-1 and Research Unit 1735 ”Structural Inference in Statistics: Adaptation and Efficiency”).