Comparison of Internal Clustering Validation Indices for Prototype-Based Clustering
Full text
This is an electronic reprint of the original article. This reprint may differ from the original in pagination and typographic detail. Author(s): Title: Year: Version: Please cite the original version: All material supplied via JYX is protected by copyright and other intellectual property rights, and duplication or sale of all or part of any of the repository collections is not permitted, except that material may be duplicated by you for your research use or educational purposes in electronic or print form. You must obtain permission for any other use. Electronic or print copies may not be offered, whether for sale or otherwise to anyone who is not an authorised user. Comparison of Internal Clustering Validation Indices for Prototype-Based Clustering Hämäläinen, Joonas; Jauhiainen, Susanne; Kärkkäinen, Tommi Hämäläinen, J., Jauhiainen, S., & Kärkkäinen, T. (2017). Comparison of Internal Clustering Validation Indices for Prototype-Based Clustering. Algorithms, 10(3), Article 105. https://doi.org/10.3390/a10030105 2017
algorithms Article Comparison of Internal Clustering Validation Indices for Prototype-Based Clustering Joonas Hämäläinen *,†, Susanne Jauhiainen †and Tommi Kärkkäinen † Faculty of Information Technology, University of Jyvaskyla, P.O. Box 35, FI-40014 Jyvaskyla, Finland; [email protected] (S.J.); [email protected] (T.K.) *Correspondence: [email protected] † These authors contributed equally to this work. Received: 13 July 2017; Accepted: 1 September 2017; Published: 6 September 2017 Abstract: Clustering is an unsupervised machine learning and pattern recognition method. In general, in addition to revealing hidden groups of similar observations and clusters, their number needs to be determined. Internal clustering validation indices estimate this number without any external information. The purpose of this article is to evaluate, empirically, characteristics of a representative set of internal clustering validation indices with many datasets. The prototype-based clustering framework includes multiple, classical and robust, statistical estimates of cluster location so that the overall setting of the paper is novel. General observations on the quality of validation indices and on the behavior of different variants of clustering algorithms will be given. Keywords: prototype-based clustering; clustering validation index; robust statistics 1. Introduction Clustering aims to partition a given dataset (a set of observations) into groups (clusters) that are separated from other groups in a twofold manner: observations within a cluster are similar to each other and dissimilar to observations in other clusters [ 1 ]. Diverse sets of clustering approaches have been developed over the years, e.g., density-based, probabilistic, grid-based, and spectral clustering [2] . However, the two most common groups of crisp (here, we do not consider fuzzy clustering [ 3 ]) clustering algorithms are partitional and hierarchical clustering [ 4 ]. Hierarchical clustering constructs a tree structure from data to present layers of clustering results, but because of the pairwise distance matrix requirement, the basic form of the method is not scalable to a large volume of data [ 5 ]. Moreover, many clustering algorithms, including hierarchical clustering, can produce clusters of arbitrary shapes in the data space, which might be difficult to interpret for knowledge discovery [6]. The two aims of clustering for K groups in data are approached in the partitional algorithms, most prominently in the classical K-means [ 4 , 7 ], by using two main phases: initial generation of K prototypes and local refinement of the initial prototypes. The initial prototypes should be separated from each other [ 4 , 8 ]. Lately, the K-means ++ algorithm [ 9 ], where the random initialization is based on a density function favoring distinct prototypes, has become the most popular variant to initialize the K-means-type of an algorithm. Because the prototype refinement acts locally, we need a globalization strategy to explore the search space. This can be accomplished with repeated restarts through initial prototype regeneration [ 10 ] or by using evolutionary approaches with a population of different candidate solutions [11]. One can utilize different error (score) functions in partitional clustering algorithms [ 12 ]. Mean is the statistical estimate of the cluster prototype in K-means and the clustering error is measured with the least-squares residual. This implies the assumption of spherically symmetric, normally distributed data with Gaussian noise. These conditions are relaxed when the cluster prototype is replaced, e.g., with a robust location estimate [ 13 – 15 ]. The two simplest robust estimates of location Algorithms 2017,10, 105; doi:10.3390/a10030105 www.mdpi.com/journal/algorithms
Algorithms 2017,10, 105 2 of 14 are median and spatial median, whose underlying spherically symmetric distributions are uniform and Laplace distributions, respectively. If the type of data is discrete, for instance, an integer variable with uniform quantization error [ 16 ], then the Gaussian assumption is not valid. Median, given by the middle value of the ordered univariate sample (unique only for odd numbers of points [17]), can, like the mean, be estimated from the marginal distribution being inherently univariate. The spatial median, on the other hand, is truly a multivariate, orthogonally equivariant location estimate [ 18 ]. These location estimates and their intrinsic properties are illustrated and more thoroughly discussed in [ 17 , 19 ]. The median and spatial median have many attractive statistical properties, especially since their so-called breakdown point is 0.5, i.e., they can handle up to 50% of contaminated and erroneous data. In a typical unsupervised scenario, one does not possess any prior knowledge of the number of clusters K . Finding the best possible representation of data with K groups is difficult because the number of all possible groupings is the sum of Stirling numbers of the second kind [ 19 ]. Defining validation measures for clustering results has been, therefore, a challenging problem that different approaches have tried to overcome [ 20 – 25 ]. The quality of a clustering result can be measured with a Clustering Validation Index (CVI). The aim of a CVI is to estimate the most appropriate K based on the compactness and separation of the clusters. Validation indices can be divided into three categories [26] : internal, external, and relative. An external validation index uses prior knowledge, an internal index is based on information from the data only, and in a relative CVI, multiple clustering results are compared. A comprehensive review of clustering validation techniques up to 2001 was provided in [ 27 ]. There exists also alternative approaches for determining the number of clusters, e.g., by measuring the stability of the clustering method [ 28 ] or using multiobjective evolutionary approaches [11,29]. In this paper, we continue the previous work reported in [ 30 ] by focusing on a comparison of the seven best internal CVIs, as identified in [ 30 ] and augmented by [ 22 ]. The earlier comparisons, typically reported when suggesting novel CVIs, only include K-means as the partitional clustering algorithm [ 22 , 30 – 36 ]. Here, this treatment is generalized by using multiple statistical estimates as a cluster prototype and to define the clustering error, under the currently most common initialization strategy as proposed in [ 9 ] (which is also generalized). Note that prototype-based clustering can also be conducted with an incremental fashion [ 37 – 39 ]. However, here were restrict ourselves on the batch versions of the algorithms, which can be guaranteed to converge in a finite number of iterations (see Section 2.1). The definitions of the considered validation indices are also extended and empirically compared with K-means, K-medians, and K-spatialmedians (using spatial median as a prototype estimate) clustering results for a large pool of benchmark datasets. According to our knowledge, there exists no previous work that compares CVIs with multiple different distance metrics. Our aim is to sample the main characteristics of the indices considered and to identify what indices most reliably refer to ground truth values of the benchmark datasets. Note that by their construction, all CVIs considered here can also be used to suggest the number of clusters in hierarchical clustering. The structure of the article is as follows. After this introductory section, we describe generalized prototype-based clustering, discuss its convergence, and also present the generalized versions of cluster initialization and indices in Section 2. Our experimental setup is described in Section 3, and the results are given and discussed in Section 4. Finally, conclusions are drawn in Section 5. 2. Methods In this section, we introduce and analyze all the necessary formulations for clustering and cluster validation indices. 2.1. General Prototype-Based Clustering and Its Convergence As described above, prototype-based partitional clustering algorithms comprise two main phases. First, they start with an initial partition of the data, and second, the quality of this partition is
Algorithms 2017,10, 105 3 of 14 improved by a local search algorithm during the search phase. The initial partition can be obtained based on many different principles [ 4 , 8 ], but a common strategy is to use distinct prototypes [ 9 ]. Most typically, the globalization of the whole algorithm is based on random initialization with several regenerations [10] . Then, the best solution with the smallest clustering error is chosen as the final result. The iterative relocation algorithm skeleton for prototype-based partitional clustering is presented in Algorithm 1[12,16]. Algorithm 1: Prototype-based partitional clustering algorithm. Input: Dataset and the number of clusters K. Output: Partition of dataset into Kdisjoint groups. Select Kpoints as the initial prototypes; repeat 1. Assign individual observation to the closest prototype; 2. Recompute the prototype with the assigned observations; until the partition does not change; As stated in [ 17 ] (see also [ 19 ]), the different location estimates for a cluster prototype arise from different lp -norms to the q -th power as the distance measure and the corresponding clustering error function; mean refers to k·k2 2 ( p=q= 2), median is characterized by k·k1 1 ( p=q= 1), and the spatial median is given by k·k1 2 ( p= 2, q= 1). Hence, generally the repetition of Steps 1 and 2 from the search phase of Algorithm 1locally minimize the following clustering error criterion: J({bk}) = K ∑ k=1 ∑ xi∈Ck kxi−bkkq p. (1) Here {bk} , k= 1, . . . , K denote the prototype vectors to be determined and {xi}N i=1 , xi∈Rn refers to the given set of n -dimensional observations. The interpretation of (1) is that each observation xi is assigned to cluster kwith the closest prototype on the lp-norm: Ck={1≤k≤K| kxi−bkkp≤ kxi−bk0kp∀k6=k0}. Hence, as noted in [ 40 ], another more compact way of formalizing the clustering error criterion reads as J({bk}) = N ∑ i=1 min k=1,...,Kkxi−bkkq p, (2) which more clearly shows the nonsmoothness of the clustering problem, because the min -operator is not classically differentiable (see [ 17 ] and references therein). This observation gives rise to a different set of clustering algorithms that are based on nonsmooth optimization solvers [41]. However, despite the nonsmoothness of the error function, it can be shown that the search phase of Algorithm 1decreases the clustering error, ensuring local convergence of the algorithm in finite many steps. We formalize this in the next proposition. The proof here is a slight modification and simplification of the more general treatment in [ 19 ], Theorem 5.3.1, along the lines of the convergence analyses in different problem domains, as given in [42–44]. Proposition 1. The repeated Steps 1 and 2 of Algorithm 1decrease the clustering error function (2) . This guarantees convergence of the algorithm in finite many steps. Proof. Let us denote by superscript t the current iterates of the prototypes {bt k} with the initial candidates for t= 0. If assignments to clusters and to the closest cluster prototypes do not change,
Algorithms 2017,10, 105 4 of 14 we are done, so let us assume that the repeated step 1 in Algorithm 1has identified at least one 1≤j≤Nsuch that, for xj∈Ct k, there exists a better prototype candidate: kxj−bt kkp>kxj−bt k0kpfor some k06=k. (3) Then, a direct computation, using monotonicity of the function k · kq for q={ 1,2 } and reflecting the change in the assignments, gives J({bt k}) = K ∑ k=1 ∑ xi∈Ct k kxi−bt kkq p= K ∑ k=1 ∑ xi∈Ct k i6=j kxi−bt kkq p+kxj−bt kkq p > K ∑ k=1 ∑ xi∈Ct k i6=j kxi−bt kkq p+kxj−bt k0kq p = K ∑ k=1 ∑ xi∈Ct+1 k kxi−bt kkq p(4) ≥ K ∑ k=1 ∑ xi∈Ct+1 k kxi−bt+1 kkq p=J({bt+1 k}). Here, the last inequality follows from the repeated Step 2 of Algorithm 1and from the optimization-based definitions of mean/median/spatial median as minimizers of the lq p -norm [ 17 ] over a dataset: ∑ xi∈Ct+1 k kxi−bt+1 kkq p=min b∈Rn∑ xi∈Ct+1 k kxi−bkq p≤∑ xi∈Ct+1 k kxi−bt kkq pfor all k. (5) Because (4) and (5) are valid for any reallocated index j satisfying (3) , we conclude that the clustering error strictly decreases when a reallocation for a set of observations occurs in Algorithm 1. To this end, because there exists only a finite number of possible sets Ct k , we must have Ct+1 k=Ct k after a finite number of steps t7→ t+1. This ends the proof. The K-means++ initialization method utilizes squared Euclidean distance-based probabilities to sample initial prototypes from the data points. In Algorithm 2, this initialization strategy is generalized for varying lp -norms to the q -th power. Note that Algorithm 2is the same as the K-means++ initialization algorithm when p=q= 2. In order to be successful, one needs to assume in Algorithm 2 that the dataset {xi}N i=1 has at least K distinct data points, which is a natural and reasonable assumption. In Step 2, the probability for each point xi to be selected as the next initial prototype is proportional to the distance to the closest already selected prototype divided by the value of the clustering error Function (2) for the already selected prototypes. Clearly, in each iteration, the most distant points (with respect to the previously selected initial prototypes) have the highest probability of being selected. Algorithm 2: General K-means++-type initialization. Input: Dataset {xi}N i=1and the number of clusters K. Output: Initial prototypes {bk}K k=1. 1. Select b1=xiuniformly randomly, i=1, . . . , N; for k=2, k =k+1, k ≤Kdo 2. Select bk=xiwith probability minj=1,...,k−1kxi−bjkq p J({bj}k−1 j=1),i=1, . . . , N; end
Algorithms 2017,10, 105 5 of 14 2.2. Cluster Validation Indices From now on, for a given number of clusters K , we denote, by {ck} and {Ck} , k= 1, . . . , K , the best prototypes and divisions obtained after a fixed number of repeated applications of Algorithm 1. When K= 1, we denote the prototype, i.e., the mean, median, or spatial median, of the whole data with m . Moreover, we let JK denote the corresponding clustering error over the whole data and Jk K=∑xi∈Ckkxi−ckkq pto refer to the corresponding final within-cluster errors. Cluster validation considers the quality of the result of a clustering algorithm, attempting to find the partition that best fits the nature of the data. The number of clusters, given as a parameter for many clustering algorithms (such as the ones presented in Section 2.1), should be decided based on the natural structure of the data. Like the best clustering solution, the number of clusters is also not always clear and many ’right’ answers can exist (see, e.g., [ 19 ], Figure 5). The number can also depend on the resolution, i.e., whether the within- and betweencluster separabilities are considered globally or locally. Here, we focus on the CVIs based on the internal criteria. The validation indices measure how well the general goal of clustering—high similarity within clusters and high separability between clusters—is achieved. These are considered with measures of within-cluster (Intra) and between-cluster (Inter) separability, for which lower and higher values are better, respectively. Normally, a division between Intra and Inter is made and the optimal value is at the minimum or maximum, based on the order of the division. In Table 1, the best internal validation indices (as determined for the K-means-type of clustering in [ 30 ], augmented with [ 22 ]) are introduced in a general fashion for the lq p -norm setting. All except one of the indices have been modified in such a way that the optimal number of clusters can be found at the minimal value. Only the Wemmert–Gançarski index, which has a unique pattern of the general formula, is given in the original form, where the maximum value indicates the optimal number of clusters. In Table 1, if the formula that combines Intra and Inter depends on the generated clusters, then this is indicated with the corresponding parameters. Table 1. Internal cluster validation indices. Name Notation Intra Inter Formula KCE [30] KCE K× JKIntra WB-index [22] WB K× JK K ∑ k=1nkkck−mkq p Intra Inter Calinski–Harabasz [24] CH (K−1)× JK(N−K)×K ∑ k=1nkkck−mkq p Intra Inter Davies–Bouldin [23] DB 1 nk Jk K+1 nk0Jk0 Kkck−ck0kq p 1 K K ∑ k=1max k6=k0 Intra(k,k0) Inter(k,k0) Pakhira, Bandyopadhyay, and Maulik [45] PBM K× JKmax k6=k0(kck−ck0kq p)× J1Intra Inter 2 Ray–Turi [25] RT 1 N× JKmin k6=k0kck−ck0kq p Intra Inter Wemmert– Gançarski ([46]) WG kxi−ckkq pmin k6=k0kxi−ck0kq p 1 N K ∑ k=1max0, nk−∑ i∈Ik Intra(i) Inter(i) As can be seen from the formulas of the indices, there are a lot of similarities in how different indices measure the within- and between-cluster separability. For example, the clustering error straightforwardly measures the similarity within clusters and, therefore, almost all of the indices include it in their measure of Intra. In case of between-cluster separability, it is common to measure, for instance, the distance between cluster prototypes or between cluster prototypes and the whole data prototype. The rationale behind the index structures and their more detailed descriptions can be found in the original articles.
Algorithms 2017,10, 105 6 of 14 2.3. On Computational Complexity The computational complexity of the prototype-based clustering is O(RTKNn) , where T is the number of iterations needed for convergence and R is the chosen number of repetitions of joint Algorithms 1and 2. As the clustering itself is quite time-consuming, especially with large datasets, it is only natural to also consider the complexity of the indices to avoid excessively complex computations. Here, the KCE index has an advantage in not requiring any extra calculation after the clustering solution has been obtained. For the indices that go through the prototypes once, here the WB and CH that measure the prototype distances to the whole data prototype, the complexity is O(Kn) . Indices that measure the distances between all the prototypes, such as DB, PBM, and RT, have complexity O(K2n) . In our tests, WG is the index with the highest complexity, O(KNn) , going through the whole data, comparing points and the prototypes. A commonly used and generally well performing index, Silhouette (see, e.g., [ 30 , 33 ]), goes through the whole data twice when calculating its values and therefore its complexity is O(N2n) . With large datasets of at least hundreds of thousands of observations, this might be even more complex than the clustering task itself, with the chosen values of R and K and the observed value of T (see Figure A1) in Section 4. If computationally more involved indices would be used, also application of more complex clustering algorithms should be considered. Therefore, Silhouette was excluded from our tests. 2.4. About Earlier Validation Index Comparisons There has been a lot of research on cluster validation, including comparisons of different validation indices and clustering algorithms. Often when a new index is proposed, the work also includes a set of comparisons that conclude that the new index is the best one. In [ 34 ], eight common CVIs were compared and with 5% additional noise, different densities, and skewed distributions, most indices were able to find the correct number of clusters. However, only three of them were able to recognize close subclusters. In their tests, S_Dbw was the only CVI that suggested the correct number of clusters for all datasets. In our previous tests in [ 30 ], the S_Dbw also recognized the close subclusters in Sim5D2, but it did not perform that well in general. Often no single CVI has a clear advantage in every context, but each is best suited to a certain kind of data. This was also the conclusion in [ 33 ], where 30 different indices with 720 synthetic and 20 real datasets were compared. However, a group of about 10 indices were found to be the most recommendable, including Silhouette, Davies–Bouldin * and Calinski–Harabasz at the top. Also, in the earlier extensive comparison [ 47 ], where 30 indices were compared, the authors suggested that if different datasets were used for testing, the order of the indices would change but the best ones—including Calinski–Harabasz, Duda–Hart, and the C-index—would still perform well. 3. Experimental Setup Next, we test the indices in Table 1with different distance measures, i.e., with different prototype-based clustering algorithms. The index values are calculated with the distance corresponding to the clustering method used, i.e., city-block with the K-medians, squared Euclidean with the K-means, and Euclidean with the K-spatialmedians. All datasets were scaled to the range of [ − 1,1]. All the tests were run on MATLAB (R2014a), where a reference implementation on both the validation indices and the general clustering Algorithm 1with the initialization given in Algorithm 2were prepared. The impact of the necessary amount of repetitions of Algorithms 1and 2was tested with multiple datasets (S-sets, Dim-sets, A1,Unbalance), comparing the clustering error and the cluster assignments. With 100 repetitions, the minimum clustering error and the corresponding cluster assignments were stabilized and an appropriate clustering result was found. This result with the minimum clustering error was used for computing the CVI value. To test the indices, we used the basic benchmark datasets described in detail in [ 48 ], with the two other synthetic datasets http://users.jyu.fi/~jookriha/CVI/Data/ as given in [ 30 ] (see Figure 1).
Algorithms 2017,10, 105 7 of 14 These benchmark sets are synthetic datasets, suggested for use when testing any algorithm dealing with clustering spherical or Gaussian data. Here, we restrict ourselves to the benchmarks with at most 20 clusters, because the interpretation and knowledge discovery from the clustering results with a large number of prototypes might become tedious [ 6 , 49 ]. Therefore, the number of clusters was also tested with K=2−25. Sim5D2 PCA of Sim5D10 Figure 1. Scatter plots of Sim5 datasets. In addition, we use six real datasets that include Steel Plates,Ionosphere, and Satimage (Train) from the UCI Machine Learning Repository, https://archive.ics.uci.edu/ml/datasets.html Iris and Arrhythmia from MATLAB’s sample datasets, https://se.mathworks.com/help/stats/_bq9uxn4.html, and the USPS dataset. https://www.otexts.org/1577 A summary of all these datasets can be seen in Table 2. For these real datasets, even if there are class labels provided, we do not compare the clustering results with the class information because of the completely unsupervised scenario with the internal validation indices. Moreover, the classes need not correspond to the clusters determined by the prototype-based clustering algorithm, since the probability density functions of the classes are not necessarily spherically symmetric. For these datasets, we therefore only study and compare the stability of the suggestions on the numbers of clusters for different indices. Table 2. Description of datasets. Data Size Dimensions Clusters Description S5000 2 15 Varying overlap G2 2048 1–1024 2 Varying overlap and dimensionality DIM 1024 32–1024 16 Varying dimensionality A3000–7500 2 20–50 Varying number of clusters Unbalance 6500 2 8 Both dense and sparse clusters Birch 100,000 2 1–100 Varying structure Sim5 2970 2–10 5 Small subclusters close to bigger ones Data Size Dimensions Classes Description Iris 150 4 3 Three species of iris Arrhythmia 452 279 13 Different types of cardiac arrhythmia Steel Plates 1941 27 7 Steel plates faults Ionosphere 351 34 2 Radar returns from the ionosphere USPS 9298 256 10 Numeric data from scanned handwritten digits Satimage (Train) 6435 36 6 Satellite images Finally, our datasets include the following: A1, with 20 spherical clusters and some overlap; the S-sets, including four datasets with 15 Gaussian clusters, and cluster overlap increasing gradually from S1 to S4;Dim-sets, including six datasets with 16 well-separated clusters in high-dimensional space and dimensions varying from 32 to 1024; a subset of Birch2, including 19 datasets
Algorithms 2017,10, 105 8 of 14 with 2–20 clusters with their centroids on a sine curve; Unbalance, with eight clusters in two separate groups, the one having three dense and small clusters and the other five more sparse and bigger clusters; and a subset of G2, with 20 datasets—the lowest and highest overlap in ten different dimensions from 1 to 1024. Finally, together with the six real datasets, we had altogether 62 datasets in our tests. 4. Results In this section, we provide the results of the clustering validation index tests with K-medians, K-means, and K-spatialmedians clustering. Results for the synthetic datasets are combined in Table A1, where each cell includes the results for all three methods with ‘cb’ referring to the city-block distance ( p=q= 1), ‘se’ to the squared Euclidean distance ( p=q= 2), and ‘ec’ to the Euclidean distance ( p= 2, q= 1). In addition, the convergence properties of the clustering algorithms are compared for varying Kvalues. 4.1. CVIs for Synthetic Datasets For the Dim-sets, results were equal (and correct) in all dimensions from 32 to 1024 and for the G2-sets results were equal (and correct) from dimension eight upwards. Therefore, these have been excluded from Table A1. Correct suggestions for the number of clusters are marked in bold. The most challenging synthetic datasets seem to be Unbalance,Sim5D2, and Sim5D10. Only a few indices were able to recognize the correct number and no single index managed to solve both the Unbalance and the Sim sets. As concluded in the previous studies (see Section 2.4), different indices seem to work better with different kinds of datasets. However, there are also a lot of differences in the general performances of the tested CVIs. The overall success rates for the CVIs, i.e., for how many of the datasets (%) it gave correct suggestions, can be seen in Table 3, listed separately for each distance measure. Table 3. Right suggestions for the 56 synthetic datasets (number of right suggestions/number of datasets). Index City-Block Squared Euclidean Euclidean KCE 85.7% 87.5% 85.7% WB 87.5% 80.4% 87.5% CH 58.9% 85.7% 57.1% DB 60.7% 60.7% 62.5% PBM 87.5% 64.3% 89.3% RT 60.7% 58.9% 64.3% WG 94.6% 96.4% 92.9% In conclusion, the WG index outperforms all the other indices in all three distance measures and clustering approaches. WB and KCE also perform very well in general. For some indices, the performances vary between different distances; for example, CH works very well with the squared Euclidean distance, while PBM clearly works better with city-block and Euclidean distances. As a whole, the recommendation for the use of indices is as follows: for the original K-means, WG, KCE, and CH are the three best indices, and for the robust variants with K-medians and K-spatialmedians, WG, PBM, and WB have the highest success rate. 4.2. CVIs for Real Datasets As mentioned, here we only observe and compare the stability of the clustering results. The results are combined in Table 4. With real datasets, a typical behavior of the internal validation indices is the suggestion of only a small number of clusters. This is especially true for KCE and CH, even if we know that there are observations from multiple classes, with the class boundaries having unknown