• Nie Znaleziono Wyników

Comparative Assessment of Some Selected Methods of Determining the Number of Clusters in a Data Set

N/A
N/A
Protected

Academic year: 2021

Share "Comparative Assessment of Some Selected Methods of Determining the Number of Clusters in a Data Set"

Copied!
11
0
0

Pełen tekst

(1)

A C T A U N I V E R S I T A T I S L O D Z I E N S I S

FO LIA O EC O N O M IC A 206, 2007

J er zy Kor zeniewski *

CO M PA R A TIV E A SSESSM EN T O F SO M E SELECTED M E T H O D S O F D E T E R M IN IN G T H E NUM BER O F CLUSTERS IN A DATA SET

Abstract. T his paper is an attempt to compare the performance o f an algorithm for determ ining the number o f clusters in a data set proposed by the author with other m ethods o f determ ining the number o f clusters. The idea o f the new algorithm is based on the com parison o f pseudo cumulative distribution functions o f a certain random variable. For a fixed w indow size we draw К different points and for every point we find the corresponding lim iting p oin t in the mean shift procedure. Then we check if the distance (e.g. Euclidean) between every pair o f the limiting points is greater than the w indow size. A n alogou sly we determ ine the pseudo cum ulative distribution functions for different numbers К ol clusters. Out o f all pseu do cum ulative distribution functions we pick the proper one i.e. the last one” (with respect to K ) which has a horizontal phase. Other m ethods ol determ ining the number o f clusters in a data set are compared with the proposed algorithm in a number o f examples o f tw o dim ensional data sets for different clustering m ethods (/с-means clustering and minimum distance agglom eration).

Key words: cluster analysis, number o f clusters, computer algorithm , mean shift method.

The new algorithm is based on the sample m ean shift m ethod used to estim ate the local m axim a o f the density function of a random vector. I he idea o f this m ethod proposed by D. C o m a n i c i u and P. M e e r (1999) is as follows. Let ... be a set of n points from d im e n s io n a l

Euclidean space. The kernel estim ator of m ultivariate density function with kernel K ( x ) and window size h is given by the form ula

1. IDEA OF NEW A LG O R ITH M

(2)

The optim al kernel in the sense o f m inimum square error is the Epanech- nikov kernel given by the form ula

е д = ГŁ [0, с' ,<‘, + 2 ><1 - л >' otherwisei f „ A < 1 P )

where cd is the volum e of a unit sphere in d-dim ensional Euclidean space. It is easy to find an estim ator o f the gradient o f the density function

= nhd , P )

F o r the Epanechnikov kernel we will arrive at the form ula

£ [ x - x i = ^ d- i r ( l K 1 ^ nn cd n x,«S,(x) ntl n \ x , e S k(x) The quantity (4) M*(*) = ( l/n , Z [ x - x j ) = l /пх £ x , - x (5) x,6S,(x) x , e S t(x)

is called the window/sample m ean shift. The m ean shift always moves the sample in the direction o f the greatest increase in density, therefore, if we keep on m oving the sample by the vector given by form ula (5) we will get convergence tow ards the centre o f the local density m aximum (see: C o - m a n i c i u , M e e r (1999)). By the limiting point of a given starting point we will understand the centre of the last window in the sequence of the m ean shift procedures.

In connection with the algorithm proposed below it is im portant to rem ark th at the window is shifted at every step of the procedure in the direction o f the nearest local density m axim um . T he location o f this m aximum depends on the size h of the window. The smaller the value of h the m ore local is the character of the m axim um , the greater the value o f h the m ore global is the m axim um . In particular, if the window size h is greater than the greatest distance between any two d ata points every d a ta point will be shifted tow ards the same limiting point.

(3)

Form ally, the algorithm can be described in the following steps. Step 1. F o r К = 2 we draw dependently 2 d a ta points and for each point we find the corresponding limiting point in the m ean shift procedure for a fixed window size h.

Step 2. We check if am ong all pairs of limiting points (for К = 2 there is only one pair) there exists at least one pair of points with the distance smaller th an h.

Step 3. We repeat step 1 and step 2 10000 times in order to find the probability o f m eeting the condition from step 2.

Step 4. We repeat steps 1, 2 and 3 for all window sizes h from interval (0, max. distance) with h increasing discreetly by small increments e.g. 1/1000 o f the m aximal distance. As a result we get a pseudo cumulative distribution function for к = 2.

Step 5. We repeat steps 1, 2, 3 and 4 for К = 3 ,4 ,5 ,..., (e.g.) 20. The proper num ber of clusters that is picked up with the help o f the above presented algorithm is the one equal to the greatest К that cor­ responds to the curve possessing a “ horizontal phase” significantly below than 1. H orizontal phase is defined in the following way: it is a part of the curve o f the length of at least 1/20 o f the m edian ol all distances between pairs o f points and each point o f this p art corresponds to a pro­ bability smaller or greater by ко m ore than 0.01 than the probabilities for all other points from the p art preceding the point. The num bers 1/20 o f the m edian and 0.01 were found by the m ethod o f trial and error and obviously are not to be changed - are supposed to be working for an arbitrary d a ta set. The horizontal phases are usually very evident and if the num bers 1/20 and 0.01 were slightly different it wouldn’t change the algorithm ’s performance. The appearance of the m edian o f all pairwise distances m akes it necessary to estimate it. 1 he following way of estima­ ting it was adopted. If the data set has less than 200 elements we com ­ pute all pairwise distances and pick up the median. If the set is larger we draw w ithout replacement 300 pairs of elements and take the median o f the found 300 pairwise distances. The idea behind this algorithm is as follows.

Let us consider a two dimensional d ata set (see Fig. 1) consisting of three equally spaced identical unimodal clusters — each cluster centre e.g. 80 pixels away from each of the other clusters. Every draw n point will be shifted in the m ean shift procedure to the very centre o f its cluster because the cluster density increases with getting close to cluster s centre. 1 herefore, if we draw 2 points the probability o f meeting the step 2 condition is equal to the probability of drawing 2 points from the same cluster and should stay constant no m atter if the window size h is equal to 20, 30 or 70 pixels. If the window size exceeds 80 pixels the probability jum ps to 1 on

(4)

a short segment o f the horizontal axis because all set points (including the 2 draw n) correspond to the same limiting point. Similar situation will take place in the case of draw ing 3 points with the horizontal phase (the constant probability) being obviously higher. W hen we draw 4 points the probability o f m eeting step 2 condition has to be equal to 1 even for very small window sizes because some 2 points have to belong to the same cluster and therefore have the same lim iting point. F rom the graph presenting the curves for the considered d ata set it is evident why we should pick the curve that is the last to possess the horizontal phase. The length o f the horizontal phase is connected with the distance between the clusters’ centres and the height on which the horizontal phase is placed is connected with the num ber of points in the cluster due to which the phase is created.

Fig. 1. A n exem plary set o f three identical, equally spaced clusters from a tw o dim ensional E uclidean space (on the right) and an approximate graph o f pseudo cum ulative distribution

functions (on the left)

2. O T H E R M E T H O D S O F D E T E R M IN IN G T H E N U M B E R O F C L U ST E R S

There is some difficulty in com paring the algorithm described in the previous section with other m ethods o f determ ining the num ber o f clusters in a d a ta set because all m ethods which can be found in literature determine the optim al num ber of clusters for a given clustering m ethod. We chose four m ethods whose perform ance is better than that o f other m ethods ( S u g a r , J a m e s , 2003). In the following form ulae К denotes the num ber o f clusters which have to be constructed by some m ethod, B ( K) and W(K) denote, respectively, the between and within cluster variance. The first

(5)

m ethod is the C aliński-H arabasz index for which we should choose К that maximizes the value given by the formula

B( K) /( K - 1 )

(6) The second m ethod is the K rzanow ski-Lai index given by form ula (7)

DIFF(K) К Ц К ) =

where

D I F F ( K + 1)

(V)

DI FF( K) = ( K - 1)21“Щ К - 1) - K 2'JW(K) (8)

and again we should seek К th at maximizes this index. The third m ethod is the H artigan index given by form ula (9)

* ( « - ( » - К

í j - 1)

(9)

in connection with which we should choose smallest К for which the index is smaller or equal to 10. The forth m ethod is based the silhouette index which for the i-th element is given by the form ula

b(i) — fl(i)

max{a(i), b(i)}

where a(i) is the average distance between the i-th element and all other points in its cluster b(i) is the average distance to points in the nearest cluster. We should choose К that maximizes the average value of s(i).

Ail four m ethods will be checked for two quite different in nature clustering m ethods i.e. /с-means clustering and nearest neighbour agglome­ ration algorithm .

3. P E R FO R M A N C E A N A L Y SIS

We will try to com pare how all five m ethods perform for six different two dimensional d ata sets. The sets were either created or chosen so as to represent well separated clusters, badly separated clusters, clusters with similar num bers o f elements and clusters with different num bers of elements.

(6)

f t ■fr # *& # # ■ S e l l Set 2 S e t 3 . Л \ : $ 1 # ■ .m,. ■ ■ $ /: / т : ■' Set 5 Set 4

Set 6 - data set, 300 points generated from three normal distributions

Set 6 data set, 300 points generated from three normal distributions Fig. 2. Six investigated tw o dim ensional sets o f points S o u r c e : sets 1-5 - own constructions, set 6 - G o r d o n 1999.

(7)

T a b l e 1

Num bers o f clusters as shown by the four compared indices for the six analysed data sets

Set

fc-means clustering Minimum distance agglomeration Silhouette index Caliński— Harabasz Hartigan Krzanowski -Lai Silhouette index Caliński— Harabasz Hartigan Krzanowski -L ai 1 2 7 > 8 5 > 1 5 5 3 2 3 5 > 7 5 > 7 3 3 3 3 5 8 > 9 4 > 8 5 5 5 4 4 7 > 8 7 > 8 5 3 5 5 10 10 > 1 2 10 6 4 4 4 6 4 6 > 7 2 3 5 2 2 S o u r c e : own calculations. Probability Probability 1 ". sd. « tl.______ 1 ' r~--5 d. 0.5 - 0.5 100 200 300 400 100 200 300 400

Window size [pixels] Window size [pixels]

(8)

F o r Set 1 which consists of quite evident 4 clusters the algorithm proposed showed unquestionable 4 clusters. However, for this seemingly easy to handle set all other m ethods give wrong indications for both clustering methods.

F o r Set 2 which consists of 3 (rather than 2) clusters the algorithm proposed showed the proper num ber, all other m ethods perform ing rather poorly.

F o r Set 3 which consists o f 5 (rather than 4) clusters the algo­ rithm proposed showed the proper num ber, all other m ethods per­ form ing so-so.

F o r Set 4 which consists o f 5 (rather than 4) clusters, differing from the previous set only in indistinct borders between clusters, the algorithm proposed showed the proper num ber, all other m ethods perform ing badly or very badly.

F o r Set 5 which consists o f 8 clusters the algorithm proposed showed 7 clusters all other m ethods perform ing very badly.

F o r Set 6 which is a very fuzzy set and which can be described as consisting o f 3 or 4 clusters the algorithm proposed showed 4 or 5 clusters, all other m ethods perform ing very poorly ap art from the silhouette index m ethod which did better than our algorithm.

Probability Probability 1 6 cl. •:.'s d.— • - í d. 1 6 d. .. 5 cl. -A Л » • уУ • ' -4 d. / . 3d. - A " s** .3d. 0.5 2 d. 0.5 .2d. 100 200 300 Window size Set 3 400 [pixels] 100 200 300 400

Window size [pixels)

(9)

Probability Probability Window size Set 5 / / ' • 4 ci. 0 / / [pixels] 100 200 300 400

Window size [pixels]

Set 6

Fig. 5. Curves o f the new method for sets 5 and 6 S o u r c e : own investigations.

4. C O N C L U SIO N S

The examples presented in the previous section allow to form ulate the following conclusions.

1. The algorithm proposed seems to be interesting because it is entirely different from other m ethods as it does not depend on any m ethod of classifying objects to particular clusters.

2. O ther m ethods o f determining the num ber o f clusters are heavily dependent on the output results o f the cluster construction m ethod as one can see from the num bers in Tab. 1. The silhouette index perform s not so badly for the /с-means clustering while it gives entirely erroneous results for the agglom eration clustering. The contrary situation is in the case of the H artigan index. The other two m ethods are m ore stable with respect to the cluster construction m ethod but still give indications different, in m ost cases, by 2 clusters.

(10)

3. The algorithm proposed is nonparam etric i.e. does not require any assum ptions about the d ata set we investigate. The only num ber the al­ gorithm needs is the num ber of replications needed to construct the curves. The num ber of 10 000 adopted in the paper seems to be sufficient for the sets th at should be divided into not m ore than a dozen or so clusters. If the num ber o f clusters gets higher and, in consequence, the num ber of elements in the smallest cluster gets smaller we m ay need m ore than 10 000 to detect the smallest cluster. However, cluster analysis, in general, is not concerned with dividing d ata sets into m any small clusters.

4. H orizontal phases with which the algorithm is concerned are always fairly evident. There are two sources of possible mistakes that can be m ade in the proposed algorithm. One is the level on which the horizontal phase should be considered as the “ last” one and therefore pointing to the proper num ber o f clusters, the other is the minimum length o f horizontal phases. The first problem is less dangerous because if we assume the m inim um num ber of elements that the smallest cluster should consist of, it will imply the probability level for the “last” horizontal phase. The second problem is connected with the distance of two closest cluster centres and cannot be helped in any simple way, therefore, the only way out seems to be adopting an artificial level of this distance as it was suggested earlier (1/20 o f the m edian of pairwise distances).

5. The algorithm’s speed is about 5 seconds on a 1 M hz computer for “one curve” in the case of a two dimensional d a ta set consisting o f 400 elements.

R EFEREN CES

C o m a n i c i u D. , M e e r P. (1999), Mean Shift Analysis and Applications, IEEE Int. Conf. Com puter V ision (IC C V ’99), Kcrkyra, Greece, 1197-1203.

G o r d o n A. D . (1999), Classification, Chapman & H all, N ew York.

S u g a r C. A. , J a m e s G . M. (2003), Finding the N umber o f Clusters in a D ataset: An Information - Theoretic Approach, JA SA , 98, 750-763.

Jerzy Korzeniewski

O C E N A P O R Ó W N A W C Z A W Y BR A N Y C H M E T O D W Y Z N A C Z A JĄ C Y C H IL O ŚĆ SK U PIE Ń W Z B IO R Z E D A N Y C H

A rtykuł niniejszy jest próbą oceny porównawczej algorytmu wyznaczającego ilość skupień w zbiorze danych, zaproponow anego przez autora, z innymi m etodam i wyznaczania ilości skupień. Algorytm autora oparty jest na porównaniu pseudodystrybuant pewnej zmiennej losow ej dla różnych ilości skupień. Ta zmienna losow a jest zdefiniow ana w następujący sposób.

(11)

D la u stalon ego rozmiaru okna losujemy ze zbioru danych К różnych punktów i dla każdego z tych p u nk tów znajdujemy odpowiadający mu punkt graniczny w procedurze średniego przesunięcia próby. N astępnie sprawdzamy, czy odległość (np. euklidesowa) pom iędzy każdą parą punktów granicznych jest większa od rozmiaru okna. Analogicznie wyznaczamy pseudodys- trybuanty dla różnych ilości К skupień. Ze wszystkich dystrybuant za praw idłow o określającą ilość skupień uznajemy tę, która odpow iada ostatniej (względem K ) krzywej, posiadającej fazę poziom ą. Inne m etody określania liczby skupień w zbiorze danych są porów nane z zapropo­ now anym algorytm em na przykładach kilku dw uwym iarowych zbiorów danych dla dw óch, diam etralnie różnych w naturze, m etod konstruowania skupień.

Cytaty

Powiązane dokumenty

The results show that estimate of the spectral radius that was calculated with the procedure that uses symmetric matrices grows faster than the one calculated by the procedure that

More precisely, we show that two submanifolds of type number greater than one having the same affine connections and second fundamental forms are affinely equivalent.. The type

On the other hand, if the goal is only to distinguish every two adjacent vertices in G by a vertex coloring, then this can be accomplished by means of a proper coloring of G and

Conversely, for any finite subset S of the plane, or for any finite family S of disjoint plane C-curves we construct an automorphism of the plane for which the set of fixed points

and [9]. Generally, if X is an algebraic set of pure dimension n ≥ 1, X is said to be uniruled if every component of X is uniruled. Points at which a polynomial map is not proper.

The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations... The leading dimensions

A theorem similar to Theorem A holds in the holomorphic case provided there is at most one critical point in the Julia set (see the forthcoming paper by the second author and S.. If C

It was decided to rely on statistical data on the quality of healthcare systems measured with global data such as life expectancy, infant mortality, number of medical card