An Aposteriorical Clusterability Criterion for k-Means++ and Simplicity of Clustering

In this paper, the notion of a well-clusterable data set is defined combining the point of view of the objective of k-means clustering algorithm (minimizing the centric spread of data elements) and common sense (clusters shall be separated by gaps). Conditions are identified under which the optimum of k-means objective coincides with a clustering under which the data is separated by predefined gaps. Two cases are investigated: when the whole clusters are separated by some gap and when only the cores of the clusters meet some separation condition. A major obstacle for using known clusterability criteria is their reference to the optimal clustering which is NP hard to identify. In this paper, this obstacle is overcome. Compared to other approaches to clusterability, the novelty consists in the possibility of an a posteriori (after running k-means) check if the data set is well-clusterable or not. As the k-means algorithm applied for this purpose has polynomial complexity so does therefore the appropriate check. Additionally, if k-means++ fails to identify a clustering that meets clusterability criteria, with high probability the data is not well-clusterable.


Clusterability: The Intuition and the Failed Formalizations
It is a commonly observed phenomenon that the optimality criteria of most practically used clustering algorithms (like k-means) have a high theoretical computational complexity (are NP-hard). However, these algorithms perform quite well (converge quickly enough) yielding usable output in many (though not all) practical application cases. Apparently, the data must have the property that some data sets are better clusterable than other.
Though a number of attempts have been made to capture formally the intuition behind clusterability, none of these efforts seems to have been successful, as Ben-David exhibits in [10] in depth. He points at three important shortcomings of current state-of-the-art research results: the clusterability cannot be checked prior to applying a potentially NP-hard clustering algorithm to the data, known clusterability criteria impose strong (impractical) separation constraints and the research nearly does not address popular algorithms. A recent paper by Ackerman et al. [1] partially eliminates some of these problems, but regrettably at the expense of introducing user-defined parameters that do not seem to be intuitive (in terms of one's imagination about what well-clusterable data are).

What Shall be Excluded from/Included into a Clusterability Criterion
Therefore, a different approach to defining what well-clusterable data are attempted in this paper. As Ben-David mentioned, the research in the area does not address popular algorithms except for -separatedness clusterability criterion related to k-means proposed by Ostrovsky et al. [20]. This paper is intended to contribute to applicability of clusterability criteria in that, following Ostrovsky's example, k-means is considered, and in particular its special version called k-means++, as in fact Ostrovsky did. 1 * Mieczysław A. Kłopotek klopotek@ipipan.waw.pl 1 Institute of Computer Science, Polish Academy of Sciences, ul. Jana Kazimierza 5, 01-248 Warsaw, Poland 1 Ostrovsky's algorithm differs from k-means++ in the initialization step of the first two seeds. k-means++ chooses the first seed randomly, and the subsequent seeds are chosen promoting the more distant ones (allocating to them higher probabilities of selection), whereas Ostrovsky selects carefully already the first two seeds. Then both algorithms proceed in the same way.
Furthermore, Ben-David expressed the concern that it is not a solution to the problem if the NP hardness is shifted from the data clustering algorithm to the data clusterability checking algorithm, because the problem becomes even worse. This paper addresses this concern. Last not least, the issue of the impractical gaps imposed by the clusterability criteria in the literature has been raised. Ben-David argues in [10] (see his "Smaller Gaps Between Clusters" section) that apparently the efforts in clusterability research on finding support for the hypothesis of "clustering is hard only if the clustering does not matter" have failed, mainly due to the fact that gaps between clusters that are required are too large for practical applications, as the popular algorithms behave reasonably even with significantly smaller gaps. But a closer look at the k-means objective shows (see "Failure of Gaps as a Criterion for Clusterability" section) that it does not make sense to build a clusterability criterion solely on the grounds of the gaps because k-means criterion does not rely solely on gaps between clusters, but also on their cardinalities as well as on their internal spread, which cannot be known in advance. If cardinalities are changed, k-means may prefer to split larger clusters and merge parts of them with smaller, though clearly separated clusters. If the k-means criterion shall coincide with separation of clusters, the gaps need to be large. Therefore, instead of seeking smaller gaps, this research concentrates on redefining the goal of clusterability research efforts. So it is proposed here to change the perspective. Instead of (or in addition to) seeking conditions for easiness of clustering of a given data set, one shall look for definition of a data set (data set generator) for which optimal clustering is known in advance and an algorithm returns the ground truth nearly for sure. This change of perspective will lead to a practical application of clusterability concept consisting in testing the algorithm behaviour under varying degrees of violating the clusterability conditions.
Having been freed from the need to seek the smallest possible gaps, one can also weaken the problems with NP hardness of stating the clusterability of the data set. In particular, one shall not require that it has to be said beforehand (before clustering) whether or not the data is wellclusterable. Instead one shall require that one is able to state aposteriorically whether or not the data is well-clusterable according to well-clusterability criteria that were assumed, in polynomial time. Note that this is a tremendous progress over clusterability criteria defined so far. None of the clusterability criteria discussed by Ben-David [10] fits this requirement and the criterion proposed in [1] can be shown to be invalid for simple data sets (see "Failure of Multi-modality Detection for Detection of Gaps Between Data" section, Fig. 1). This paper resolves in this way a serious bottleneck in the clusterability research. The issue of measuring the deviation from well-separatedness is not covered here. Nonetheless, the presented clusterability criterion opens a way to attack this issue also, because the criterion is verifiable ex post and the data can be checked for clusterability by at least one popular algorithm.

Clusterability Challenge in the k-Means Algorithm Family
This study is restricted to the k-means family of algorithms. The restriction is not too serious as the algorithms of this (a) (b) Fig. 1 Illustration of a special case where Ackerman's method [1] would falsely recognize clustering structure in the data a the data, b the histogram of pair-wise distances-two modes visible SN Computer Science family are broadly used and there exist quite large number of variants, starting with early work of Lloyd, Forgy, MacQueen and Hartigan-Wong, to k-means++, spherical k-means, their fuzzified version, kernel variants, k-harmonic means, and many other. 2 k-means is used also as a part of other algorithms, like those of spectral analysis [23]. While studying clusterability, we concentrate on the k-means++ algorithm's initialization phase, introduced by Arthur and Vassilvitskii [5]. It is a well-known problem with k-means basic version (with random initialization) that it tends to stick in local minima if the initial seeding is not very good. Ways to overcome this shortcoming have been sought, like the mentioned k-means++ algorithm that ensures a better seeding. However, other approaches like k-harmonic-means by Zhang et al. [26], power-k-means by Xu et al. [25] and entropy-regularized-power-k-means by Chakraborty et al. [13] that attempt to reduce the dependence of the performance on the initialization. Their advantage is that they smoothen the landscape of the optimized function so that the chance of sticking into local optima is reduced. These approaches are, however, not suitable for our purposes. The entropy-regularized-power-k-means has a target function (quality function or optimization criterion) that is definitely different from that of k-means, though many interesting theoretical properties like strong consistency have been shown. These properties do not warrant however reaching their global optimum. The k-harmonic-means target function differs also from that of k-means though it may be used as an initial phase of the algorithm (instead of a clever seeding) followed by proper k-means, and it was shown empirically that better target function values are found. Only power-k-means has the target function that agrees with that of k-means. However, its complex mathematical form makes it difficult to derive a clusterability criterion that would be superior to that proposed here for k-means++, though this would be worth investigation. Nonetheless, any data set clusterable for k-means++ should also turn out to be clusterable for power-k-means as it is less sensible to bad initialization (that can still happen with k-means++).
The following challenges have to be faced within the k-means family according to Ben-David [10]: • the clusterability criteria in the literature (e.g. Ostrovsky et al. [20]) refer to the optimal cost function value of k-means [see Eq. (1)]-but the actual value of this optimal solution is not known • people are accustomed to associate well-clusterable data with ones of large gaps between clusters-but the optimal cost function of k-means is also influenced by cluster sizes, so that the gap sufficient for one set of clusters will prove insufficient for some other (see "Failure of Gaps as a Criterion for Clusterability" section) • the cost function of k-means usually has multiple local minima and the real-world k-means algorithms usually tend to stick at some local minimum (see e.g. [24,Chapter 3]).
For these reasons, when comparing the results of various k-means brands on real data, it is hard to distil the reason why their results differ: is it because the data are not clusterable or that the cost function optimum does not agree with common sense split into well-separated clusters or the algorithm is unable to discover the optimal clustering (systematically misses it).
Therefore, a clusterability criterion is sought in this paper such that: • it is based on the gap size between clusters and other cluster characteristics, that can be computed by inspection of an obtained clustering (not referring to the optimal one), • if the clustering obtained meets the clusterability criteria, then this is the real optimal clustering, • if a special algorithm (k-means++ is meant here) fails to find a clustering meeting the clusterability criteria, then with high probability the data is not well-clusterable at all by any algorithm, • there exists the possibility to generate a data set matching the clusterability conditions for various constellations of the cluster sizes (cardinality, spread), dimensionalities, number of clusters etc.
Given such a tool at disposal, one can investigate algorithm's capability to find the optimal clustering in the easy case, compare the algorithms in their performance in an easy case, and then compare their relative performance when the clusterability property degenerates, for example via decreasing the size of the gap between clusters.

Our Contribution
This research is confined to providing the tool in terms of the new clusterability criterion, and only a small demonstration is made, how the degenerative behaviour of algorithms may be studied. Our contribution encompasses: • Two brands of well-clusterability criteria for data to be clustered via k-means algorithm, that can be verified ex post (both positively and negatively) without great computational burden [inequalities (2) and (3) in "Our Basic Approach to Clusterability" section, and inequalities (15) and (16) in "Smaller Gaps Between Clusters" section].
• Demonstration, that the structure of well-clusterable data (according to these criteria) is easy to recover [see Theorems 1(i) and 5(i)]. • Demonstration that if well-clusterable data structure (in that sense) was not discovered by k-means++, then there is no such structure in the data [with high probabilitysee Theorems 1(ii) and 5(ii)]. • Demonstration that large gaps between data clusters are not sufficient to ensure well-clusterability by k-means (see "Failure of Gaps as a Criterion for Clusterability" section).

Paper Structure
The structure of this paper is as follows: in "The Problem of Clusterability in the Previous Work" section, the previous work on the topic of clusterability is recalled and a brief introduction to the k-means algorithm and its special case k-means++ is given. "Failure of Gaps as a Criterion for Clusterability" section shows that large gaps are not sufficient for well-clusterability. "Our Basic Approach to Clusterability" section introduces the first version of well-clusterability concept and shows that data well-clustered in this sense are easily learnable via k-means++. This concept has the drawback that no data points (outliers) can lie in wide areas between the clusters. Therefore "Core-Based Approach to Clusterability" section proposes a core-based well-clusterability concept and shows that data well-clustered in this sense are also easily learnable via k-means++. The concept of cluster core itself is introduced and investigated in "Smaller Gaps Between Clusters" section and a method determining proper gap size under these new conditions is derived in "Core-Based Global k-Means Minimum" section. In "Experimental Results" section, some experimental results are reported concerning performance of various brands of k-means algorithms for data fulfilling the clusterability criteria proposed in this paper. "Discussion" section contains a brief comparison of our clusterability criteria with those discussed by Ben-David [10]. In "Conclusion" section some conclusions are drawn.

The Problem of Clusterability in the Previous Work
Clusterability Property: Easy to Use, Hard to Verify Intuitively the clusterability, as suggested by Ackerman et al. [2], shall be a function taking a set of points and returning a real value saying how "strong" or "conclusive" is the clustering structure of the data. This intuition, however, turns out not to be formalized in a uniform way. A large number of formal definitions have been proposed. Ackerman and Ben-David [2] studied several of them. They concluded that two phenomena co-occur across the various formalizations: on the one hand, well-clusterable data sets (with high "clusterability" value) are computationally easy to cluster (in polynomial time), but on the other hand identification whether or not the data is well-clusterable is NP-hard.

Major Brands of Clusterability Criteria and Their Shortcomings
Ben-David [10] performed an investigation of the concepts of clusterability from the point of view of the capability of "not too complex" algorithms to discover the cluster structure. He verified negatively the working hypothesis that "Clustering is difficult only when it does not matter" (the CDNM thesis). He considered the following notions of clusterability, present in the literature: • Perturbation Robustness meaning that small perturbations of distances/positions in space of set elements do not result in a change of the optimal clustering for that data set. Two brands may be distinguished: additive, proposed by Ackerman and Ben-David [2], and multiplicative ones, proposed by Bilu and Linial [12] (the limit of perturbation is upper-bounded either by an absolute value or by a coefficient). • -Separatedness meaning that the cost of optimal clustering into k clusters is less than 2 times the cost of optimal clustering into k − 1 clusters, by Ostrovsky et al. [20]here an explicit reference to the k-means objective is made. • (c, )-Approximation-Stability by Balcan et al. [8] meaning that if the cost function values of two partitions differ by the factor c, then the distance (in some space) between the partitions is at most . As Ben-David recalls, this implies the uniqueness of optimal solution. • -Centre Stability by Awasthi et al. [7] meaning, for any centric clustering, that the distance of an element to its cluster centre is times smaller than the distance to any other cluster centre under optimal clustering. • (1 + ) Weak Deletion Stability by Awasthi et al. [6] meaning that given an optimal cost function value OPT for k centric clusters, then the cost function of a clustering obtained by deleting one of the cluster centres and assigning elements of that cluster to one of the remaining clusters should be bigger than (1 + ) ⋅ OPT.
Under these notions of clusterability, algorithms have been developed clustering the data nearly optimally in polynomial times, when some constraints are matched by the mentioned parameters. However, these conditions seem to be rather extreme. Ben-David [10] points at concrete numerical SN Computer Science disadvantages. For example, given the (c, )-Approximation-Stability [8], polynomial time clustering requires that, in the optimal clustering (beside its uniqueness), all but an -fraction of the elements, are 20 times closer to their own cluster centre than to every other cluster centre. -Separatedness requires that the distance to its own cluster centre must be at least 200 times closer than to every other cluster element [20]. And this is still insufficient if the clusters are not balanced. A ratio of 10 7 is deemed by these authors as sufficient.
( 1 + ) Weak Deletion Stability [6] demands distances to other clusters being log(k) times the "average radius" of the own cluster. The perturbational stability [2] induces exponential dependence on the sample size.

Gap as a Component of Clusterability Criteria
One can draw a certain important conclusion from the concepts of clusterability mentioned above: people agree that a data set is well clusterable if each cluster is distant (widely separated) from the other clusters. This idea occurs in many other clusterability concepts. Epter et al. [15] consider the data as clusterable when the minimum between-cluster separation exceeds the maximum in-cluster distance (called elsewhere "perfect separation"). 3 Balcan et al. [9] propose to consider data as clusterable if each element is closer to all elements in its cluster than to all other data (called also "nice separation"). 4 k-means reflects the Balcan concept "on average" that is each element average squared distance to elements of the same cluster is smaller than the minimum (over other clusters) averaged squared distance to elements of a different cluster. Kumar and Kannan [18], explicitly concentrating on k-means objective, define clusterability via a proximity condition as follows: Any point projected on a line connecting its own cluster centre and some other cluster centre should be closer to its own cluster centre by a "sufficiently large" gap depending on the number of clusters and inverted squared cluster cardinalities.
Kushagra et al. [19] consider clusterability from the point of view of a structure in the data. They allow for noise in the data, but insist that the noise does not create structures by itself. They refrain from optimizing a cost function. They show that discovery of clusters is not possible without assumption of structure in the data or without assumption of structureless noise. Ackerman et al. [3] consider the clusterability from the perspective of distortion of clusters by malicious points. It turns out that from this perspective k-means performs better than various other algorithms. With respect to our research, they also insist that the proportions between cluster sizes play a significant role ensuring proper clustering.

Clusterability as a Function of Both Data and the Algorithm
Ackerman and Dasgupta [4] move the focus on clusterability from the clusterability as a property of the data alone to the pair of (data type, algorithm type). In that paper, they are interested in incremental algorithms only and show that an incremental version of k-means performs poorly under perfect and nice separation. In the same spirit Ben-David and Haghtala [11] investigated clusterability by k-centroidal algorithms (a class of algorithms including k-means) via robustifying an algorithm against noise in the data by either clustering the noise into separate clusters or cutting off too distant points. Tang [22] investigates a clusterability criterion for his own version of k-means, based on the requirement that the cluster centres are separated by some distance, which is dependent upon ground truth optimal clustering. Recently Ackerman et al. [1] derived a method for testing clusterability of data based on the large gap assumption. They investigate the histogram of (all) mutual dissimilarities between data points. If there is no data structure, the distribution should be unimodal. If there are distant clusters, then there will occur one mode for short distances (within clusters) and at least one for long distances (between clusters). Hence, to detect clusterability, they apply tests of multimodality, namely the Dip and Silverman tests, as suggested by Hartigan and Hartigan [16] and Silverman [21] resp.. But the criterion of a sufficiently large gap between clusters is not reflected in various clustering function objectives, for example k-means which may reach an optimum with poorly separated clusters in spite of the fact that there exists an alternative partition of data with a clear separation between clusters in the data, as demonstrated in "Failure of Gaps as a Criterion for Clusterability" section. It will be also demonstrated in "Failure of Multi-modality Detection for Detection of Gaps Between Data" section that multimodal distributions can be detected by Ackerman's method even if there is no structure in the data.

Clusterability as Agreement Between Global and Local Clustering
Cohen-Addad [14] raises the claim that data are clusterable (in terms of various stability criteria) if the global clustering can be well approximated by local one. Our work can be perceived in this spirit in that we try to achieve coincidence of clusters based on separability with global cost function minimum.

Clusterability Criteria not Verifiable a Priori
Ben-David [10] raises a further important point: It is impossible to verify a priori if the data fulfils the clusterability criterion in practically all abovementioned methods (except [1], which has a flaw by itself, see "Failure of Multi-modality Detection for Detection of Gaps Between Data" section). The reason is that these criteria refer either to all possible clusterings or to optimal clustering so that one does not have the possibility to verify in polynomial time whether or not the data set is clusterable, before one starts clustering (but usually computing the optimum is NP-hard). In this paper, however, we stress that the situation is even worse. Even at the termination of the clustering algorithm, one is unable to say whether or not the clustered data set turned out to be well-clusterable. For example, the -Separatedness criterion requires that the nearly optimal solution for clustering into k and k − 1 elements is known. While one can usually get the upper approximations for the cost functions in both cases, one needs actually the lower approximation for k − 1 in order to decide ex post if the data was well-clusterable, and hence whether or not one can say that one approximated the correct solution in some way. But this lower approximation for k − 1 can only be obtained if k − 1 = 1 . Therefore, the issue is not decidable for k > 2 . Tang's [22] criterion is certainly better, though also based on solution to optimality criterion, because one can sometimes decide ex post that the clusterability criterion was fulfilled. (the distance between clusters needs to be greater than a product of optimal clustering cost function and reversed squared roots of cluster cardinalities, which may be upper-bounded by the actual clustering cost function and the number 2.) But even if the algorithm actually finds optimal clustering, one cannot be sure that the solution is optimal even if the clusterability criterion is met.
The issue of ex post decision on clusterability seems nevertheless to be simpler to solve than the a priorical one; therefore, we will attack it in this paper. We are unaware that such an issue was even raised in the past. Though the criteria of [9,15] can clearly be applied ex post to see if the clusterability criteria hold in the resulting clustering, these approaches fail to solve the inverse issue: what if the clusterability criteria are not matched by the result clustering-is the data non-clusterable? Could no other algorithm discover the clusterable structure? One shall note at this point that the approach in [1] is different with this respect. Compared to methods requiring finding the optimum first, Ackerman's approach seems to fulfil Ben-David requirement, that one can see if there is clusterability in the data before starting the clustering process. Ackerman's clusterability criterion can be computed in polynomial time because the computation of the histogram of dissimilarities is quadratic in sample size. But at an in-depth-investigation, the Ackerman's clusterability determination method misses one important point: it requires a user-defined parameter and the user may or may not make the right guess. Furthermore, even if clusterability is decided by Ackerman's tests, it is still uncertain if k-means algorithm will be willing to find such a clustering that fits Ackerman's clusterability criterion. Beside this, as visible in Fig. 1, one can easily find counterexamples to their concept of clusterability. The left image shows that there is a single cluster there, but the histogram to the right has two modes, indicating a two-cluster structure.
In summary, the issue of an aposteriorical determination if the data were clusterable, remains an open issue. Therefore, it seems to be justified to restrict oneself to a problem as simple as possible in order to show that the issue is solvable at all. In this paper, we will limit ourselves to the issue of clusterability for the purposes of k-means algorithm. 5 Furthermore, we restrict ourselves to determine such cases when the clusterability is decidable "for sure".
The first problem to solve seems to be to get rid of the dependence on the undecidedness of optimality of the obtained solution.

A Brief Introduction to the k-Means Family
Before proceeding let us recall the definition of k-means cost function Q(C) for the clustering C.
for a dataset under some partition C = {C 1 , … , C k } into the predefined number k of clusters, C 1 ∪ ⋯ ∪ C k = , where u ij is an indicator of the membership of data point i in the cluster C j having the centre at j = 1 �C j � ∑ ∈C j . The k-means algorithm starts with some initial guess of the positions of j for j = 1, … , k and then alternating two steps: cluster assignment and centre update till some convergence criterion is reached, e.g. no changes in cluster membership. The cluster assignment step updates u ij values so that each element i is assigned to a cluster represented by the closest j . The centre update step uses the update for- The k-means++ algorithm is a special case of k-means where the initial guess of cluster centres proceeds as follows. 1 is set to be a data point uniformly sampled from (1) The k-means algorithm seems to be quite popular in various variants both in traditional, kernel and spectral clustering. Hence the results may be still of sufficiently broad importance.

SN Computer Science
. The subsequent cluster centres are data points picked from with probability proportional to the squared distance to the closest cluster centre chosen so far. For details check the paper of Arthur and Vassilvitskii [5]. Note that the algorithm proposed by Ostrovsky et al. [20] differs from the k-means++ only by the non-uniform choice of the first cluster centre. (The first pair of cluster centres should be distant, and the choice of this pair is proportional in probability to the squared distances between data elements.)

Failure of Multi-modality Detection for Detection of Gaps Between Data
Let us discuss more closely the relationship between the gap-based well-clusterability concepts developed in the literature and the actual optimality criterion of k-means. Specifically let us consider the approaches to clusterability of [1,7,9,15].
Intuitively, if the groups of data points occur in the data and there are large spaces between these groups, then it should be these groups that will be chosen as the actual clustering. On the other hand, if there are no gaps between the groups of data points, then one would expect that the data are not considered as well clusterable. Furthermore, if the data is well clusterable, one would expect a reasonable clustering algorithm to discover easily such a well-clusterable data structure.
However, these intuitions prove wrong in case of k-means. Let us first point to the fact that the method of [1] may indicate a clear bimodal structure in the data where there are no gaps in the data. We are unaware of anybody pointing at this weakness of well-clusterability in [1]: imagine a thin ring uniformly covered with data points (see Fig. 1a). One would be reluctant to say that there is a clustering structure in such data. Nonetheless, two obvious modes in such data are visible. The thinner the ring (the closer to a circle), the more obvious the reason for the multi-modality will be: one gets closer and closer to the following function. Consider the angle centred at the centre of the circle ("thin ring"). To calculate distances between points, one can restrict himself to angles with measure 0 • ≤ ≤ 180 • (or 0 ≤ ≤ ). The number of elements within the angle would be approximately proportional to this angle. The distance between cutting points of this angle on the circle, given a radius r of the circle, will amount to x = 2r sin 2 . Consequently = 2 arcsin x 2r . To determine the density of distances, a derivative has to be computed This function has a minimum at x = r and grows towards both x = 0 and x = 2r . It is reflected in the histogram in Fig. 1b, where r = 5 is assumed. As the points occur not on a circle, but on a ring, more distances close to zero occur in the histogram.

Failure of Gaps as a Criterion for Clusterability
On the other hand, even if there are gaps between groups of data, for example those required by [7,9,15], k-means optimum may not lie in the partition exhibiting gap-based well-clusterability property in spite of its existence, and not only for these gaps, but also for any arbitrary many times larger ones. As [15] is concerned, it may be considered as a special case of [9]. Awasthi et al. [7] may be viewed in turn as a strengthening of the concept of [15]. Therefore, let us discuss a situation in which both perfect and nice separation criteria are identical that is of two clusters. It will be shown that whatever is assumed in the -stability concept, k-means fails to be optimal under unequal class cardinalities. Let these clusters, C A , C B be each enclosed in a ball of radius r and the distance between ball centres should be at least 4r. It has been demonstrated in [17] that under these circumstances the clustering of data into C A , C B reflects a local minimum of k-means cost function. But it is not the global minimum, as will be shown subsequently. So the criteria of Epter et al. [15], Balcan et al. [9] and Awasthi et al. [7] cannot be viewed as realistic definitions of well-clusterability at least for k-means. Subsequently, whenever we say that a cluster is enclosed in a ball of radius r, we mean at the same time that the ball is centred at gravity centre of the cluster. Assume, for purposes of demonstration, that both clusters are of different cardinalities n A , n B and let n A > n B . It will be shown that whatever distance between both clusters, one can get such a proportion of n A ∕n B that the clustering into C A , C B is not optimal. Let us consider a d-dimensional space. Let us select the dimension that contributes most to the variance in cluster C A . So the variance along this direction amounts to at least the overall variance divided by d. Let us denote this variance component as V d . Consider this coordinate axis responsible for V d to have the origin at the cluster centre of C A . Project all the points of cluster C A on this axis. The variance of projected points will be just V d . Split the projected data set into two parts P 1 , P 3 , one with coordinate above 0 and the rest. Let P ′ 1 , P ′ 3 be the original data points which were projected onto P 1 , P 3 resp. Then C A = P � 1 ∪ P � 3 and P � 1 ∩ P � 3 = � Let the centres of P 1 , P 3 lie x 1 , x 3 away from the cluster centre. Let n 1 data points of P 1 be at most x 1 distant from the origin, and n 2 more than x 1 from the origin. Let there be n 3 data points of P 3 be at most x 3 distant from the origin, and n 4 more than x 3 from the origin. Obviously, n 1 + n 2 + n 3 + n 4 = n A , |P 1 | = n 1 + n 2 , |P 3 | = n 3 + n 4 . As zero is assumed to be the C A cluster centre on this line, also x 1 ⋅ (n 1 + n 2 ) = x 3 ⋅ (n 3 + n 4 ) holds. Furthermore, as the cluster is enclosed in a ball of radius r centred at its gravity centre, both x 1 ≤ r and x 3 ≤ r . Under these circumstances, let us ask the question whether for a V d some minimal values of x 1 , x 3 are implied. Because if so, then by splitting the cluster C A into P ′ 1 , P ′ 3 and by increasing the cardinality of C A , the split of data into P � 1 , P � 3 ∪ C B will deliver a lower Q value so that for sure the clustering into C A , C B will not be optimal. Note The n 1 points of P 1 closer to origin than x 1 are necessarily not more than x 1 distant from P 1 gravity centre. Therefore, the remaining n 2 points cannot be more distant than It is visible that that is Note that one can delimit n 2 , n 4 from below due to the relationship: . Therefore which is equivalent to By rearranging the terms one gets: Let us increase the right-hand side by adding to the nominator n 2 ⋅ r ⋅ x 1 + n 4 ⋅ r ⋅ x 3 . This implies Then we obtain Hence One can delimit n 1 + n 2 from below due to relationship . Therefore which simplifies to Clearly n 3 + n 4 < n A , which implies V d ≤ 3 ⋅ x 3 ⋅ r . This means that Now let us show that when scaling up n A it pays off to split the first cluster and to attach the contents of the second one to one of the parts of the first. Let us increase the cardinality of C A b times simply by replacing each data element by b data elements collocated at the same place in space. In this way, one keeps V d when increasing |C A | . So the sum of squared distances between centre and elements of the cluster Let n 1 + n 2 be the minority among data pointsthen x 1 is larger and x 3 is smaller of the two, because of x 1 ⋅ (n 1 + n 2 ) = x 3 ⋅ (n 3 + n 4 ) . Let P ′ 1 , P ′ 3 be the subsets of C A yielding upon the aforementioned projection the mentioned sets P 1 , P 3 . Then if one would split C A into P ′ 1 , P ′ 3 , the sum of squared distances to respective cluster centres of P ′ 1 , P ′ 3 would decrease by at least , and the distances SN Computer Science between elements of P ′ 1 and P ′ 3 (and so respective gravity centres) are at least as big as between P 1 and P 3 , so that On the other hand, combining P ′ 1 , P ′ 3 with disjoint parts P ′ 6 , P ′ 7 of C B will increase the sum of squared distances by at most n B x 2 5 , where x 5 is the distance between extreme elements of C A and C B : 2 5 . Combining these two relations, one gets Therefore, as soon as one sets b ≥ will obtain that is that for suitably large b it pays off to split C A and merge C B into parts of C A , because the optimum lies at other partition than the one of well-separatedness in terms of big distance between centres of cluster enclosing balls. See also the discussion in "Experimental Results" section on Table 1.

Our Basic Approach to Clusterability
Let us stress at this point that the issue of well clusterability is not only a theoretical issue, but it is of practical interest too. For example when one intends to create synthetic data sets for investigating suitability of various clustering algorithms. But also after having performed the clustering process with whatever method one has. The important question needs to be answered: whether or not the obtained clustering meets the expectation of the analyst. These expectations may be divided into several categories: • matching business goals, • matching underlying algorithm assumptions, • proximity to the optimal solutions.
Business goals of the clustering may be difficult to express in terms of data for an algorithm or may not fit the algorithm domain or data may be too expensive to collect prior to performing an approximate clustering. For example, when one seeks a clustering that would enable efficient collection of cars to be scrapped (disassembly network), then one has to match multiple goals, like covering the whole country, maximum distance from client to the disassembly station, and of course the number of prospective clients, which is known with some degree of uncertainty. The distances to the clients are frequently not Euclidean in nature (due to geographical obstacles like rivers, mountains, etc.), while the preferred k-means algorithm works best with geometrical distances, no upper distance can be imposed, etc. Other algorithms may induce same or different problems. So one has to check a posteriori if the obtained solution meets all criteria, does not violate constraints and is stable under fluctuation of the actual set of clients. The other two problems are somehow related to one another. For example, one may have clustered the data being a subsample of the proper data set and the question may be raised how close the subsample cluster centres are to the cluster centres of the proper data set. Known methods allow to estimate this discrepancy given that one knows that the cluster sizes do not differ too much. So prior to evaluating the correctness of cluster centre estimation one has to check if cluster proportions are within a required range (or if subsample size is relevant for such a verification). As another example consider methods of estimating closeness to optimal clustering solution under some general data distributions (like for the k-means++ [5]), but the guarantees are quite loose. But at the same time the guarantees can be much tighter if the clusters are well separated in some sense. So if one wants to be sure with a reasonable probability that the obtained solution is sufficiently close to the optimum, one would need to check if the obtained clusters are well separated in the defined sense.
With this in mind, as mentioned, a number of researchers developed the concept of data clusterability. The notion of clusterability should intuitively reflect the following idea: if it is easy to see that there are clear-cut clusters in the data, then one would say that the data set is clusterable. "Easy to see" may mean either a visual inspection or some algorithm that quickly identifies the clusters. The well-established notion of clusterability would improve our understanding of the concept of the cluster itself-a well-defined clustering would be a clustering of clusterable points. This also would be a foundation for objective evaluation of clustering algorithms. The algorithm shall perform well for well-clusterable data and when the clusterability condition would be violated to some degree, the performance of a clustering algorithm is allowed to deteriorate also, but the algorithm quality would be measured on how the clusterability violation impacts the deterioration of algorithm performance.
However, the issue turns out not to be that simple. As is well known, each algorithm seeking to discover a clustering may be betrayed somehow to fail to discover a clustering structure that is visible upon human inspection of data. So instead of trying to reflect human vision of clusterability of the data set independently of the algorithm, let us rather concentrate on finding a concept of clusterability that is both reflecting human perception and the minimum of cost function of a concrete algorithm, in our case k-means. This paper concentrates particularly on its version called k-means++.
Let us define: Definition 1 A data set is well-clusterable with respect to k-means cost function [Eq. (1)] for a given k (in brief: is well-clusterable) if (a) the data points may be split into subsets that are clearly separated by an appropriately chosen gap such that (b) the global minimum of k-means cost function coincides with this split and (c) with high probability (over 0.95) the k-means++ algorithm discovers this split and (d) if the split was found, it may be verified that the data subsets are separated by the abovementioned gap and (e) if the k-means++ did not discover a split of the data fulfilling the requirement of the existence of the gap, then with high probability the split described by points (a) and (b) does not exist.
Conditions, under which one can ensure that the minimum of k-means cost function is related to a clustering with (wide) gaps between clusters, were investigated in the paper [17].
The conditions for clusterable data set therein are rather rigid, but serve the purpose of demonstration that it is possible to define properties of the data set that ensure this SN Computer Science property of the minimum of k-means. Let us recall below the main result in this respect.
Assume that the data set encompassing n data points consists of k subsets such that each subset i = 1, … , k can be enclosed in a ball of radius r i . Let the gap (distance between surfaces of enclosing balls) between each pair of subsets amount to at least g, that is described below, as proposed in the paper [17] to ensure that the split of data into these subsets is the global optimum of k-means. and for any p, q = 1, … , k; p ≠ q , when n i , i = 1, … , k is the cardinality of the cluster i, M = max i n i , m = min i n i . These conditions are taken from [17, formulas (21) and (22)], and they ensure that the global optimum agrees with a split into clusters separated by the mentioned gap.
Please note that the quotient of the cardinality of the largest to the smallest cluster increases the size of the required gap, as may be expected from "Failure of Gaps as a Criterion for Clusterability" section. It is visible from formula (2) that both the relationship M/m and n/m matter. This formula gives the impression that this relationship may be like square root of the sum of the two. But note that g is controlled also by formula (3), where the dependence of g on n/m may become close to linear, while that on M/m will still be close to square root. As visible from "Failure of Gaps as a Criterion for Clusterability" section, the sum of squared distances to cluster centre within the cluster and between clusters decides on the point when the shift in minimal costs occurs when the disproportion between cluster sizes grows. Hence g needs to grow as square root with this disproportion M/m. The impact of n/m shall be rather viewed in the context of the number of clusters k, as with fixed m and growing n n/m may be deemed as a reflection of k. If one looks at formula (5), one sees that g depends approximately quadratically on k. This relates probably to the fact that the number of possible misassignments between clusters grows quadratically with k.
It is claimed in [17] that the optimum of k-means objective is reached when splitting the data into the aforementioned subsets. The most fundamental implication is that the problem is decidable. (2) and (3), then with high probability k-means++ (after an appropriately

Theorem 1 (i) If the data set is well-clusterable (into k clusters) with a gap defined by formulas
n p n q chosen number of repetitions) will discover the respective clustering. (ii) If k-means++ (after an appropriately chosen number of repetitions) does not discover a clustering matching formulas (2) and (3), then with high probability the data set is not well clusterable with a gap defined by formulas (2) and (3).
The rest of the current section is devoted to the proof of the claims of this new theorem, proposed in the current paper.
If one obtained the split, then for each cluster one is able to compute the cluster centre, the radius of the ball containing all the data points of the cluster, and finally one can check if the gaps between the clusters meet the requirement of formulas (2) and (3). If this requirement is met, then definitely the data set is well clusterable.
Let us look at the claim (i). As shown in [17, section 12], the global minimum of k-means coincides with the separation by abovementioned gaps. Hence if there exists a positive probability, that k-means++ discovers the appropriate split, then the probability of finding the global minimum is increased by repeating independent runs of k-means++ and picking the split minimizing k-means cost function. It will be shown that the number of repetitions needed is known in advance, if the value of the quotient M/m is bounded from above by a known number.
First consider the easiest case of all clusters being of equal sizes ( M = m ). Then the above Eqs. (2) and (3) can be reduced to ( r = r max ) A diagram of dependence of g/r on k is depicted in Fig. 2. Now let us turn to k-means++ seeding. During initialization of the algorithm, the first cluster centre 1 is selected randomly (with uniform distribution) from among all the data points . The subsequent data points are selected randomly from the (remaining) data points ∈ with probability Prob( ) = Recall that with k clusters, we have km data points as all the clusters are of equal size. (k − i)m of them are in clusters that do not have a seed yet, im are in those with a seed. The data points in clusters without a seed have the distance to the closest seed of at least the size g. On the other hand, the data points ′ in clusters with a seed have the distance to the closest seed of at most the size 2r. Let ⊂ be the set of data points in seeded clusters. Then the probability that a new cluster will be seeded The last inequalities are justified first by substituting a positive number in the denominator by a bigger one, and then both in nominator and in denominator (that is bigger than he nominator) same number is substituted by the same smaller one.
Note that the inequality (5) Hence the probability of accurate seeding ( PAS(k) ) amounts to The diagram of dependence of this expression on k is depicted in Fig. 3.
Let us denote with Pr succ the required probability of success in finding the global minimum. To ensure that the seeding was successful in Pr succ (e.g. 95%) of cases, .
k-means++ has to be rerun at least R times, with R given by R does not depend on sample size But look at the following relationship: The exponent of the last expression approaches rapidly zero, so that with increasing k within a single pass of k-means++ the optimum is reached. In fact, already for k = 2 an error of below 3% is obtained, for k = 8, below 1%, for k = 30 below 0.1%. See Fig. 3 for illustration. Let us discuss clusters with same radius, but different cardinalities. Let m be the cluster minimum cardinality, and M, respectively, the maximum. for any p, q = 1, … , k; p ≠ q , when n i , i = 1, … , k is the cardinality of the cluster i, M = max i n i , m = min i n i , Worst case g/r values are illustrated in Fig. 4. Now let us turn to k-means++ seeding. Note that with k ≥ 4 g ≥ 2r √ k M+n m from the above relations. If already i distinct clusters were seeded, then the probability that a new cluster will be seeded (under our assumptions) amounts to at least n(n p + n q + n) So again the probability of successful seeding will amount to at least: Even if M is 20 times as big as m, still the convergence to 1 is so rapid that already for k = 2 the clustering success is achieved with 95% success probability in a single repetition. An illustration is visible in Fig. 5.
It has been shown that if the data is well clusterable, then within practically a single clustering run the seeding will have the property that each cluster obtains a single seed. But what about the rest of the run of k-means? As in all these cases g ≥ 2r , then, as shown in [17], the cluster centres will never switch to balls encompassing other clusters, so that eventually the true cluster structure is detected and minimum of Q is reached. This would complete the proof of claim (i). The demonstration of claim (ii) is straight forward. Note that if a clustering discovered by k-means fulfils the conditions of well-clusterability, then the data set is clusterable for sure, by definition. If the data were not well-clusterable, then k-means++ for sure not find a clustering with the property of being wellclusterable, because it does not exist. If the data were well clusterable, then k-means++ would have failed to identify it with probability of at most 1 − Pr succ . So denote with W the event that the data is well-clusterable. Further denote with D the event that the k-means++ algorithm states that the data is well clusterable. It will be shown below that the probability P(¬W|¬D) is high.
The last inequality is true because the well-clusterable data are in practice extremely rare, and for sure less frequent than not well-clusterable ones.
Please note that a kind of worst-case analysis was presented above. It is obvious from this discussion that the probability of seeding of k distinct clusters depends on the characteristics of the data. The smallest gap between clusters was referred to in the above, but it may turn out that some clusters are stronger separated. This will automatically increase their probability of being hit so that the overall probability of hitting unhit clusters will increase significantly.

Smaller Gaps Between Clusters
Well-clusterability was considered in the previous section under the assumption of large areas between clusters where no data points of any cluster will occur. It will be shown subsequently that this assumption may be relaxed so that spurious points are allowed between the major concentrations of cluster points. But to ensure that the presence of such points will not lead the k-means procedure astray, core parts of the clusters will be distinguished and the subsequent Theorem 3 demonstrates that once a cluster core is hit by k-means initialization procedure, the cluster is preserved over subsequent k-means iterations.
It has been proven in [17,Theorem 17] that is the radius of a ball centred at B and enclosing its cluster. If the distance between the cluster centres A, B amounts to 2 AB + g , g > 0 (g being the "gap" between clusters), if one picks any two points, X from the cluster of A and Y from the cluster of B, and recluster both clusters around X and Y, then the new clusters will preserve the balls centred at A and B of radius g/2 (called subsequently "cores") each (X the core of A, Y the core of B).
The validity of a complementary theorem will be demonstrated here.
Theorem 3 Let A, B be cluster centres. Let AB be the radius of a ball centred at A and enclosing its cluster and it also is the radius of a ball centred at B and enclosing its cluster. Let cAB be the radius of a ball centred at A and enclosing "vast majority" of its cluster and it also is the radius of a ball centred at B and enclosing "vast majority" of its cluster. If the distance between the cluster centres A, B amounts to 2 AB + g , g > 0 ( g = 2r cAB being the "gap" between clusters), if one picks any two points, X from the ball B(A, r cAB ) and Y from the ball B(A, r cAB ) , and recluster both clusters around X and Y, then the new clusters will be identical to the original clusters around A and B.
Definition 2 If the gap between each pair of clusters fulfils the condition of either of the above two theorems, then we say that we have core-clustering.
Proof For the illustration of the proof see Fig. 6.
The proof does not differ too much from the previous one, and the previous Theorem 2 is a special case of Theorem 3.
Consider the two points A, B being the two centres of double balls. The inner call represents the core of radius r cAB = g∕2 , the outer ball of radius ( = AB ), enclosing the whole cluster. Consider two points, X, Y, one being in each core ball (presumably the cluster centres at some stage of the k-means algorithm). To represent their distances faithfully, a 3D space is needed at most.
Let us consider the plane established by the line AB and parallel to the line XY. Let X ′ and Y ′ be orthogonal projections of X, Y onto this plane. Now let us establish that the hyperplane orthogonal to XY and passing through the middle of the line segment XY, that is the hyperplane containing the boundary between clusters centred at X and Y does not cut any of the balls centred at A and B. This hyperplane will be orthogonal to the plane of Fig. 6 and so it will manifest itself as an intersecting line l that should not cross outer circles around A and B, being projections of the respective balls. Let us draw two solid lines k, m between circles O(A, AB ) and O(B, AB ) tangential to each of them. Line l should lie between these lines, in which case the cluster centre will not jump to the other ball. In order for the line l to lie between m and k, the middle point of the line segment CE shall lie between these lines.
Let us introduce a planar coordinate system centred at O with X axis parallel to lines m, k, such that A has both coordinates non-negative and B non-positive. Let us denote with the angle between the lines AB and k. Given the assumption that the distance between A and B equals 2 + 2r cAB , then the distance between lines k and m amounts to 2(( + r cAB ) sin( ) − ) . Hence the Y coordinate of line k equals (( + r cAB ) sin( ) − ).
So the Y coordinate of the centre of line segment CE shall be not higher than this. Let us express this in the coordinate system: where y OC is the y-coordinate of the vector ����� ⃗ OC , etc. Note, however, that So let us examine the circle with centre at A. Note that the lines CD and E * F * are at the same distance from the line C ′ D ′ . Note also that the absolute values of direction coefficients of tangentials of circle A at C ′ and D ′ are identical. The more distant these lines are, as line CD gets closer to A, the y AC gets bigger, and y E * A becomes smaller. But from the properties of the circle, it is visible that y AC increases at a decreasing rate, while y E * A decreases at an increasing rate. So the sum y AC + y E * A has the biggest value when C is identical with C ′ and it has to be proven only that Let M denote the middle point of the line segment C ′ D ′ . As point A has the coordinates (( + r cAB ) cos( ), ( + r cAB ) sin( )), t h e p o i n t M is at distance of ( + r cAB ) cos( ) from A. But C � M 2 = r 2 cAB − (( + r cAB ) cos( )) 2 . Hence, it is necessary to show that But this condition is equivalent to: which is obviously true, as sin never exceeds 1. ◻

Core-Based Global k-Means Minimum
In the paper [17], conditions have been investigated under which one can ensure that the minimum of k-means cost function is related to a clustering with (wide) gaps between clusters. Based on the result of the preceding "Smaller Gaps Between Clusters" section, these conditions will be weakened requiring only that the big gaps exist between cluster cores and the clusters themselves are separated by much smaller gaps, equal to the size of the core.
In particular, let us consider the set of k clusters C = {C 1 , … , C k } of cardinalities n 1 , … , n k and with radii of balls enclosing the clusters (with centres located at cluster centres) r 1 , … , r k . Let each of these clusters C i have a core C i around the cluster C i centre of radius r i and cardinality n i such that for ∈ [0, 1) One is interested in a gap g between cluster cores C 1 , … , C k such that it does not make sense to split each cluster C i into subclusters C i1 , … , C ik and to combine them into a set of new clusters S = {S 1 , … , S k } such that S j = ∪ k i=1 C ij . A g is to be found such that the highest possible central sum of squares combined over the clusters C i would be lower than the lowest conceivable combined sums of squares around respective centres of clusters S j . Let Var(C) be the variance of the cluster C (average squared distance to set C gravity centre; with one exception, however: if referring to the core of any of the clusters C i , The cluster C i gravity centre is computed, not the core C i gravity centre, so also with the Q function). Let C ij = C ij ∩ C i be the core part of the subcluster C ij . Let r ij be the distance of the centre of core subcluster C ij to the centre of cluster C i . Let v ilj be the distance of the centre of core subcluster C ij to the centre of core subcluster C lj . So the total k-means function for the set of clusters (C 1 , … , C k ) will amount to: And the total k-means function for the set of clusters (S 1 , … , S k ) will amount to: Should (C 1 , … , C k ) constitute the absolute minimum of the k-means target function, then Q(S) ≥ Q(C) should hold, which is fulfilled if: Note that on the left-hand side of the inequality, the portion of the data outside of the cores has been ignored. This portion of the data would have made the left-hand side even bigger.
The above inequality is implied by: To maximise ∑ k j=1 n ij r 2 ij for a single cluster C i of enclosing ball radius r i , note that you should set r ij to r i . Let m j = arg max j∈{1,…,k} n ij . If one sets r ij = r i for all j except m j , then the maximal r im j is delimited by the relation ∑ k j=1;j≠m j n ij r ij ≥ n im j r im j . So So if one can guarantee that the gap between cluster balls (of clusters from C ) amounts to g then surely because in such case g ≤ v ilj for all i, l, j.
By combining inequalities (10), (12) and (13), one sees that the global minimum is granted if the following holds: One can distinguish two cases: either (1) there exists a cluster S t containing two subclusters C pt , C qt such that SN Computer Science t = arg max j |C pj | and t = arg max j |C qj | (maximum cardinality subclasses of their respective original clusters C p , C q or (2) not. Consider the first case. Let C p , C q be the two clusters where C pt and C qt be two subclusters of highest cardinality within C p , C q resp. This implies that n pt ≥ 1 k n p , n qt ≥ 1 k n q . Also this implies that for i ≠ p, i ≠ q n it ≤ n i ∕2.

Note that
So, in order to fulfil inequality (14), it is sufficient to require that This of course maximized over all combinations of p, q.
Let us proceed to the second case. Here each cluster S j contains a subcluster of maximum cardinality of a different cluster C i . As the relation between S j and C i is unique, one can reindex S j in such a way that actually C j contains its maximum cardinality subcluster C jj . Let us rewrite the inequality (14).

This is met if
This is the same as: This is fulfilled if: Let M be the maximum over n 1 , … , n k . The above holds if Let m be the minimum over n 1 , … , n k . The above holds if This is the same as The above will hold, if for every i = 1, … , k So the inequality (14) is fulfilled, if both inequality (15) and inequality (16) are held by an appropriately chosen g.
In summary, it has been shown that Theorem 4 Let C = {C 1 , … , C k } be a partition of a data set into k clusters of cardinalities n 1 , … , n k and with radii of balls enclosing the clusters (with centres located at cluster centres) r 1 , … , r k . Let each of these clusters C i have a core C i of radius r i and cardinality n i around the cluster centre such that for p ∈ [0, 1) Then if the gap g between cluster cores C 1 , … , C k fulfils conditions expressed in formulas (15) and (16) then the partition C coincides with the global minimum of the k-means cost function for the data set.

Core-Based Approach to Clusterability
After the preceding preparatory work, a theorem analogous to Theorem 1 will be proven, but now allowing for smaller gaps between clusters. (16) and (15), with r i replaced by their maxima, then with high probability k-means++ (after an appropriately chosen number of repetitions) will discover the respective clustering. (16) and (15).

(ii) If k-means++ (after an appropriately chosen number of repetitions) does not discover a clustering matching formulas (16) and (15) (with r i replaced by their maxima), then with high probability the data set is not well clusterable with a gap defined by formulas
The rest of the current section is devoted to the proof of the claims of this theorem.
If one obtained the split, then one is able to compute for each cluster the cluster centre, the radius of the ball containing all the data points of the cluster but the most distant ones, constituting at most of the quality function for the cluster, and finally one can check if the gaps between the cluster cores meet the requirement of formulas (16) and (15). So one is able to decide that one has found that the data set is well clusterable. So let us look at the claim (i). As demonstrated in preceding "Core-Based Global k-Means Minimum" section, the global minimum of k-means coincides with the separation by abovementioned gaps. Hence if there exists a positive probability, that k-means++ discovers the appropriate split, then by repeating independent runs of k-means++ and picking the split minimizing k-means cost function one will increase the probability of finding the global minimum. It will be shown that one can know the number of repetitions needed in advance, if an upper bound of the quotient M/m is assumed.
Let us assume it is granted that For an illustration of this dependence see Fig. 7. So let us turn to k-means++ seeding. If already i distinct cluster cores were seeded, then the probability that a new cluster core will be seeded (under our assumptions, when k ≥ 4 as previously) amounts to at least So again the probability of successful seeding will amount to at least: For an illustration of this dependence see Fig. 8. Apparently in the limit the above expression lies at about (1 − ) k−1 .
So to achieve the identification of the clustering with probability of at least Pr succ (e.g. 95% ), one will need R runs of k-means++ where Note that The effect of doubling k is that is it is sublinear in the expression 1 − (1 − ) k−1 , hence R grows slower than reciprocally logarithmically in k and p. For an illustration of this relation, see Fig. 9.
So far we have concentrated on showing that if the data is well clusterable, then within practically reasonable number of k-means++ runs the seeding will have the property that each cluster obtains a single seed. But what about the rest of the run of k-means? As shown in "Smaller Gaps Between Clusters" section, the cluster centres will never switch to balls encompassing other clusters, so that eventually the true cluster structure is detected and minimum of Q is reached. This would complete the proof of claim (i). The demonstration of claim (ii) is straight forward. If the data were well clusterable then k-means++ would have failed to identify it with probability of at most 1 − Pr succ . As the well-clusterable data are in practice extremely rare, the failure of the algorithm to identify a wellclusterable structure induces with probability of at least Pr succ . that no such structure exists in the data. A detailed proof follows the reasoning of the last part of the proof of Theorem 1.

Goals of Experiments
In order to illustrate the issues raised in this paper, three types of experiments were performed. The first experiment, performed on synthetic data, is devoted to the mismatch of gaps between subsets of data and the clusterings obtained by common clustering algorithms. The results are shown in Table 1. The second, performed on synthetic data (Table 2), and third, performed on real data (Table 3), are devoted to demonstration that k-means++ is able to discover well-clusterable data. In particular, it is shown that: (1) If a dataset is well clusterable as defined in Theorems 1 or 5 (based on Definition 1) then k-means++ is able to identify the best clustering (both for real-world datasets and synthetic ones), (2) If k-means++ cannot find a clustering satisfying wellclusterability, there is no good clustering structure, fitting those definitions, hidden in data (with high probability) for all k-means style algorithms.    DNase  orig  2  0  69  39  0  0  61  39  DNase  orig  2  0.1  59  38  0  0  62  38  DNase  g/2  2  0  0  0  0  0

Problem of Gap Insufficiency
In "Failure of Gaps as a Criterion for Clusterability" section, we drew attention to the fact that fixing gap is an insufficient criterion to define well-clusterability for k-means like (or centre-based) algorithms. The unbalanced sample can lead to change in clustering optimum position. To confirm it, an experiment reported in Table 1 on synthetic data for a number of algorithms from k-means family and some other was performed. The k-means implementation kmeans from the R package stats in versions "Hartigan-Wong", "Lloyd", "Forgy", "MacQueen" was used. The algorithms were run with nstart parameters equal 1, 10 and 20. Additionally, experiments with the function cmeans (implementing Fuzzy c-means algorithm) from the package e1071 in versions "cmeans" and "ufcl" were performed. For comparison, the single link algorithm as implemented in the hclust function of the package stats was run. We implemented our own version of initialization of the k-means++ algorithm and used it in combination with the standard kmeans of R. Two variants of k-means++ were used: one with a single start and one with two starts. We fix the gap parameter to be equal g∕r max = 2 , as, e.g. proposed in so-called perfect clusterability criterion.
With increase of the spread between cluster sizes, all but single link algorithm have increasing difficulty in detecting the "perfect" clusters. The additionally displayed indicator relQ (relative quality, the quotient of the achieved k-means cost function to the smallest one) explains the reason: k-means optimizes k-means clustering function and single link does not.

k-Means++ Discovering Well-Clusterable Data for Synthetic Data
In Tables 2, 3 and 4, illustrating the second and third experiment sets, the following abbreviations in column titles were used: Errors k-means means the number of errors (not recognizing the correct clustering) per 100 runs by the k-means algorithm with random initialization with 1 start. Errors k-means++ means the same, respectively. WC disc. means the number of times per 100 runs that the k-means++ discovered the well-clusterable structure in the data, whereas WC not disc. means the number of times k-means++ did not discover such a structure. Both are split into two categories: cc-correct clustering in the sense of the assumed cluster structure, wc-wrong clustering in the same sense.
The set-up of the second experiment is as follows: a generator with parameters k (number of clusters), M, m (minimum and maximum cluster size), d (dimensionality), (share of variance outside of core) and gp (the minimum gap size compared to the one required to testify that wellclusterable structure was found). Some parameters are fixed for this experiment: M = 75, m = 45, d = 10 , and only k, and gp are varied. In each run, a new sample is generated.
You see from Table 2 that k-means++ almost always discovers the well-clusterable structure in the data when it exists (it failed one time in 1800 experiments) and when it failed, the discovered structure was non-well-clusterable one. In 1800 experiments, when the well-clusterable structure did not exist, it did not discover a well-clusterable structure. It is worth noting that given the gap between the clusters is half as big as the well-clusterability gap, k-means++ discovered nearly always (except for 4 cases) the intrinsic structure in the data. Interestingly, k-means discovers the intrinsic structure in the data when k = 2 . But it fails when the number of clusters is bigger and the increase of the gaps between clusters does not improve its performance.

k-Means++ Discovering Well-Clusterable Data for Real Data
The set-up for the third experiment is as follows. Datasets from the R library with at least 100 records were selected ("DNase", "iris", "Theoph", "attenu", "faithful", "infert", "quakes", "randu" ). Non-numeric columns were removed, the numerical columns were normalized (mean = 0, SD = 1) and a clustering via k-means++ into k (= 2,3,5) clusters with 200 starts was performed and this was considered as the "ground truth" clustering. Then 100 times clustering experiments were performed computing the statistics as in the second experiment for the original data set and for data set modified so that the gaps between clusters were equal g/2, g, 2g where g is the gap required by the well-clusterability condition.
In an analogous way, kddcup data downloaded from the website https ://sci2s .ugr.es/keel/categ ory. php?cat=clas&order =ins#sub2 was processed. Not the entire set but rather randomly selected some 10,000 records from it were used. This extra data set was used to show the performance of the clustering for a larger number of clusters (2,4,8,16, 32, 64 and 128). As visible, the algorithm tackles the increasing number of clusters correctly.
One sees that both k-means++ and k-means do not perform well for the original data set. But if the gaps between clusters amount to at least half the well-clusterability gap, k-means++ discovers the intrinsic clustering. k-means does so only when k = 2 . k-means++ discovers always the wellclusterable structure when it exists and does not if does not exist. If k > 2 , k-means is not helped by increasing the gap between clusters.
Summarizing, it has been demonstrated empirically that (1) The gap size alone does not guarantee the discovery of clusters seen by human inspection for the class of k-meanslike algorithms. (2) If a dataset is well-clusterable as defined in Theorems 1 or 5 (based on Definition 1) then k-means++ is able to identify the best clustering (both for real-world datasets and synthetic ones). (3) If k-means++ cannot find a clustering satisfying well-clusterability, there is no good clustering structure, fitting those definitions, hidden in data (with high probability) for all k-means style algorithms.

Impact of k, Data Dimensionality and Gap on Clustering Performance
A number of further experiments have been performed on synthetic data in order to show the behaviour of several algorithms from k-means family on data that were generated with k-means++ clusterability in mind.
The impact of the parameters k (the number of clusters), d (the number of dimensions), the cluster size and the quotient of the maximum to the minimum cluster size were investigated. Additionally, the impact of the reduction of the gap between clusters on the performance of the clustering was studied (breakgap parameter indicates by what number the calculated clusterability gap was divided).
The impact was measured as follows: 10 different cluster sets were generated randomly for each value of the parameter (e.g. for k = 2, 4, 8, and 16 clusters), separated by appropriate gap. Then for 1000 times each of the algorithms was applied. Each outcome was classified as either correct or incorrect. The outcome was correct if exactly the predefined set of clusters was discovered by the run of the algorithm. Otherwise, an error was reported. Each cell in the tables contains four numbers: the average number of errors over the 10 cluster sets (number of errors out of 1000 runs), plus the standard deviation, the time in seconds taken by 1000 runs of the algorithm and the average obtained relative quality. The relative quality was measured as a quotient of the Q cost function value divided by the minimal one obtained by any algorithm for a given cluster set.
Both the case of gap separation of clusters (see Tables 5,6,7,8,9) and the gap separation of cores (see Tables 10,  kddcup  orig  2  0  82  75  0  0  25  75  kddcup  g/2  2  0  0  0  0  0  100  0  kddcup  g  2  0  0  0  100  0  0  0  kddcup  2g  2 11,12,13,14,15) were investigated. In the case of cores, correctness of proper classification of core elements was considered only. Two basic insights can be gained from all these tables. The well-clusterability concept defined in this paper is well suited for the single link algorithm. Single link is designed to identify data where there are large gaps between clusters. It is also significantly quicker than k-means++. k-means++ is the second best performing algorithm, but at the same time the slowest one. The poor comparison of speed results from the fact that only small data sets were used. Single link speed grows however quadratically in the size of the data set, while k-means speed depends quadratically on k and linearly on the size of the data set. Besides, the memory consumption of single link is quadratic in the size of the data, while that of k-means++ is linear. Hence single link is a competitor for toy examples only. Table 5 demonstrates that two-cluster task is easy for all the algorithms except for ufcl variant of Fuzzy-c-means. However, with an increase in the number of clusters, the capability of detecting the optimal clustering deteriorates strongly except for the two mentioned algorithms. The cmeans variant of Fuzzy c-means is the least affected among algorithms 1:14. Understandably, the variants of k-means with more restarts perform better than those with smaller number of restarts. Same conclusions can be drawn from the core-based clusterability experiment summarized in  Table 10, but of course the off-core elements contribute to worsening of the performance. The impact of dimensionality is shown in Tables 6 and 11. The increase of dimensionality slightly deteriorates the performance (compared to the impact of the number of clusters), and in case of cmeans it seems to improve it.
Tables 8 and 13 present the influence of the cluster sizes on the performance. The increase of cluster size negatively influences the performance except for cmeans which seems to take advantage of the increased sample size.
The spread of sample sizes, as illustrated by Tables 7 and 12 apparently does not affect the performance. (Though again cmeans takes advantage of it in the case represented by Table 7.) This would mean that the spread is quite well captured by our formula on g.
The effect of decreasing the gap size below the value determined by our formulas, as shown in Tables 9 and 14, surprisingly worsens the performance of cmeans and k-means++ only. Traditional k-means algorithms with 20 restarts outperform k-means++ apparently. This would mean that k-means++ loses its advantage of high probability of hitting distant points in case of small gaps because these distant points may be points within the same cluster rather than points of distinct clusters.
As visible from Table 15, the share of off-core variance seems not to affect the performance of the algorithm, except for deteriorating cmeans performance.

Discussion
Ben-David [10] investigated several clusterability notions under the following criteria: • practical relevance-most real-world data sets should be clusterable; • existence of quick clustering algorithms • existence of quick clusterability testing algorithms • some popular algorithms should perform well on clusterable data.
As the practical relevance is concerned, Ben-David found that the clusterability criteria he investigated are usually not met because of the impractically large gap between cluster centres is required. Our proposed clusterability criteria are as impractical as the ones he investigated-large gaps are required and their size grows with the spread of cluster sizes, the number of clusters, the cluster radius. This is due among others to the fact that k-means does not explore directly the gaps between clusters. With this respect, our proposal does not constitute a progress.
As the algorithm complexity is concerned, k-means++ has no computational disadvantage over the algorithms Ben-David considered. The gain one has is that usually one iteration of k-means is needed to establish the final result (the whole complexity resides in the initialization stage). With respect to efficient testability of the clusterability conditions Ben-David complains about the problem that checking clusterability condition requires knowledge of the optimal clustering that is NP-hard to find. With our proposal, we make here a major progress. Given an output clustering, if one checks that the distances between clusters match the requirements imposed on the gap g, one is assured that one has found the optimal clustering. On the other hand, if the data is clusterable in our sense, then it is highly unlikely that the standard k-means++ algorithm does not find it.
With respect to the last requirement, one can say that k-means++ is actually a popular algorithm and it behaves reasonably.

Clusterable Data Sets for Varying Values of k
The described clusterability criteria are based on the knowledge of the k value to check for. The following questions can be raised in this context: • Does there exist some another k for which the clusterability criterion holds? • Can one "guess" beforehand what k shall one check in order to check for potential clusterability?
Let us restrain to non-core cases only here. The first question has one trivial and some non-trivial answers. If k is equal to sample size, then the clusterability condition is trivially fulfilled.
But given a data set is clusterable for k, what can one say about clusterability for k + k � ( k ′ ≥ 1 )? Assume that the optimal clustering for k + k � , C (k+k � ) , engages such clusters C (k+k � ) j , j = 1, … , k + k � that each contains objects from different clusters from the optimal clustering for k,C (k) . Then one can have the case that cluster centres of clusters C (k+k � ) j are for each element in the cluster C i C (k) of k clustering at least r (k) i = r i away from the border of the ball enclosing cluster C i C (k) . This would be impossible because in such a case clustering C (k) would have a cost function lower than the clustering C (k+k � ) . Therefore, consider a cluster C (k+k � ) j with centre at the distance at least r i and at most 2r i from the cluster C (k) i . It has to have a radius of at least g − r i > r i , where g is the gap for k clusterability of the data set. Each element of the cluster C (k) i is then at most 3r i away from the centre of C (k+k � ) j . The required gap g ′ for k + k � clusterability would amount to more than 2(g − r i ) > 2r i . Which means that all elements of the cluster C (k) i must belong to C (k+k � ) j . Under these circumstances only k − 1 clusters of the clustering C (k+k � ) are non-empty which is a contradiction. If one of the clusters of C (k+k � ) is identical with one from C (k) , then one can drop it and reason as above. Hence, if a data set is k and k + k � clusterable, then each of the clusters in C (k+k � ) must be contained in one of the clusters from C (k) .
Furthermore, the cluster with the largest radius needs to be split for sure. Now consider a k + k � -means++ clustering where the data set is k-clusterable. As each of the clusters C (k+k � ) is a subset of one of the clusters from C (k) , the smallest distance between clusters in C (k+k � ) would be for sure smaller than the required gap g for C (k) clusters. Hence seeking for k < K clusterability could be run as follows. Perform K-means++. Check for clusterability. remove one of the centres of two closest clusters ( K ∶= K − 1 ). Recluster with seeds being the remaining centres. And repeat the procedure till clusterability is found or K = 1.

Clusterability Criteria for Other Clustering Algorithms and Cluster Models
Algorithms from the k-means family are known to work well for Gaussian-like data, where clusters are generated based on compactness. However, for data distributed differently (e.g., concentric rings), k-means usually fails. Therefore, in such situations, clustering algorithms, such as spectral clustering or kernel function based clustering are claimed to better handle such data by leveraging the connectivity information. This picture needs to be modified slightly. Notably, the k-means underpins also several spectral clustering algorithms like ones based on the combinatorial Laplacians, normalised Laplacians and random-walk Laplacians. There exist also kernel-based variants of k-means algorithms. Therefore, the results about cluster separation presented in this research will apply in those cases also. This means that the questions asked about easiness of clustering for spectral methods may be studied in a similar way as discussed in this paper, but not in the original data space but rather in the spectral space (spanned by eigenvectors assigned to lowest eigenvalues). Of course, an investigation would be necessary into the issue how the well-separatedness in the spectral space would transpose to properties of the clusters in the original space. The very same applies to kernel-k-means, where the clustering in the feature space follows the paradigm of classical k-means, so that the results of this paper affect the feature space. Again, a study of the various kernel functions that are typically applied, would be necessary in order to determine the relationship between well-separatedness in the feature space and the cluster shapes and/or separation in the original space.
Note also, that, as shown in this paper (see "Failure of Gaps as a Criterion for Clusterability" section), the claim that k-means works well for Gaussian distributions needs also to be verified in case of unbalanced clusters. Visually separated clusters can be clumped together and a visually uniform cluster may be split into parts already by the k-means cost function. Furthermore, with high probability, the k-means algorithm with random initialization will not find the intrinsic clustering even if the clusters are well separated and the cost function points at the clustering into wellseparated clusters (see "Experimental Results" section).

Conclusions
We have defined the notion of a well-clusterable data set from the point of view of the objective of k-means clustering algorithm and common sense in two variants-without any data points in the large gaps between clusters and with data points there. The novelty introduced here, compared to other work on this topic, is that one can a posteriori (after running k-means) check if the data set is well-clusterable or not. Let us make a comparison to the results of other investigators in the realm of well-clusterability, in particular presented in [1, 2, 7-9, 15, 20].
If the data is well clusterable according to criteria of Perturbation Robustness, or -Separatedness, or (c, )-Approximation-Stability or -Centre Stability or (1 + ) Weak Deletion Stability or Perfect Separation, one can reconstruct the well-clustered structure using appropriate algorithm. But only in case of Perfect Separation or Nice Separation, you can decide that you have found the structure, if you have found it. Note that you have no warranty that you will find Nice Separation if it is there. But for none of these ways of understanding well-clusterability one is able to decide (neither a priori nor a posteriori) that the data is not wellclusterable if the well-clustered structure was not found (unless by brute force).
The only exception constitutes formally the method of Multi-modality Detection, as proposed in [1], which tells us a priori that the data is or is not well-clusterable. However, as we have demonstrated, by the example in Fig. 1 in "Failure of Multi-modality Detection for Detection of Gaps Between Data" section, data can be easily found that can foolish this method, so that it discovers well-clusterability in case when there is none. Under the definitions of well-clusterability presented in this paper, one gets a completely new situation. It is guaranteed that if the well-clusterable structure is there, it will be detected with high probability. One can check a posteriori that the structure found is the well-clusterable structure if it is so, with 100% certainty. Furthermore, if the (k-means++) algorithm did not find a well-clusterable structure then with high probability it is not there in the data.
The paper contains a couple of other, minor contributions. The concept of cluster cores has been introduced such that if a seed of k-means once hits each core then there is guarantee that none of the cluster centres will ever leave the cluster. It has been shown that the number of reruns of k-means++ is small when a desired probability of success in finding the  [20], are required in order to state that the data is well clusterable, and still the probability of detecting the well-clusterable structure is much higher (even close to one in a single k-means++ run). The procedure elaborated for constructing a well-clusterable data set, ensuring that the k-means cost function absolute minimum is reached for a predefined data partition may find applications in some testing procedures of clustering algorithms.
Of course a number of research questions with respect to the topic of this paper remain open. First is the issue of constructing tight (or at least tighter) bounds for estimation of required gaps between clusters. Second is an investigation how the violations of these minimum values influence the capability of k-means algorithms to detect either the absolute minimum of their cost function or achieving a partition that is intuitively considered by humans as "good clustering".  Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creat iveco mmons .org/licen ses/by/4.0/.