Docsity

More Clustering-Mining and Distributed Queries-Lecture Notes, Study notes of Distributed Database Management Systems

Toggle sidebar
bg1
8 More About Clustering
We continue our discussion of large-scale clustering algorithms, covering:
1. Fastmap, and other ways to create a Euclidean space from an arbitrary distance measure.
2. The GRGPF algorithm for clustering without a Euclidean space.
3. The CURE algorithm for clustering odd-shaped clusters in a Euclidean space.
8.1 Simple Approaches to Building a Euclidean Space From a Distance Measure
Any
n
points can be placed in (
n
,
1)-dimensional space, with distances preserved exactly.
Example 8.1 :
Figure 19 shows howwe can place three points
a
,
b
, and
c
, with only a distance measure
D
given, in 2-dimensional space. Start by placing
a
and
b
distance
D
(
a; b
) apart. Draw a circle of radius
D
(
a; c
) around
a
and a circle of radius
D
(
b; c
) around
b
. By the triangle inequality, which
D
must obey,
these circles intersect. Pick one of the two points of intersection as
c
.
2
D(a,b)ab
c
D(b,c)D(a,c)
Figure 19: Placing three p oints in two dimensions
However, we usually have far too many points to try to place them in one fewer dimension. A more
brute-force approach to placing
n
points in a
k
-dimensional space, where
k<<n
, is called
multidimensional
scaling
.
1. Start with the
n
points placed in
k
-dim space at random.
2. Take as the \error" the
energy
of a system of springs, each of length
D
(
x; y
), that we imagine are
strung between each pair of points
x
and
y
. The energy in a spring is the square of the dierence
between its actual length and
D
(
x; y
).
3. Visit each point in turn, and try to place it in a position that minimizes the total energy of the
springs. Since moving points around can aect the optimal position of other points, wemust visit
points repeatedly,until no more improvements can be made. At this p oint, we are in a local optimum,
whichmayor may not b e the global optimum.
Example 8.2 :
Suppose wehave three points in a 3-4-5 \right triangle," as suggested in Fig. 20. If we try to
place these points in one dimension, there must be some stretching and shrinking of springs. The optimum
conguration, also shown in Fig. 20, is when the springs of length 3 and 4 are compressed to 7/3 and 10/3,
while the spring of length 5 is stretched to 17/3. In this conguration, the total energy of the system is
(3
,
7
3
)
2
+(4
,
10
3
)
2
+(5
,
17
3
)
2
=4
=
3.
2
31
docsity.com
pf3
pf4
pf5

Partial preview of the text

Download More Clustering-Mining and Distributed Queries-Lecture Notes and more Study notes Distributed Database Management Systems in PDF only on Docsity!

8 More Ab out Clustering

We continue our discussion of large-scale clustering algorithms, covering:

  1. Fastmap, and other ways to create a Euclidean space from an arbitrary distance measure.
  2. The GRGPF algorithm for clustering without a Euclidean space.
  3. The CURE algorithm for clustering o dd-shap ed clusters in a Euclidean space.

8.1 Simple Approaches to Building a Euclidean Space From a Distance Measure

Any n p oints can b e placed in (n 1)-dimensional space, with distances preserved exactly.

Example 8.1 : Figure 19 shows how we can place three p oints a, b, and c, with only a distance measure D given, in 2-dimensional space. Start by placing a and b distance D (a; b) apart. Draw a circle of radius D (a; c) around a and a circle of radius D (b; c) around b. By the triangle inequality, which D must ob ey, these circles intersect. Pick one of the two p oints of intersection as c. 2

a D(a,b) b

c

D(a,c) D(b,c)

Figure 19: Placing three p oints in two dimensions

However, we usually have far to o many p oints to try to place them in one fewer dimension. A more brute-force approach to placing n p oints in a k -dimensional space, where k << n, is called multidimensional scaling.

  1. Start with the n p oints placed in k -dim space at random.
  2. Take as the \error" the energy of a system of springs, each of length D (x; y ), that we imagine are strung b etween each pair of p oints x and y. The energy in a spring is the square of the di erence b etween its actual length and D (x; y ).
  3. Visit each p oint in turn, and try to place it in a p osition that minimizes the total energy of the springs. Since moving p oints around can a ect the optimal p osition of other p oints, we must visit p oints rep eatedly, until no more improvements can b e made. At this p oint, we are in a lo cal optimum, which may or may not b e the global optimum.

Example 8.2 : Supp ose we have three p oints in a 3-4-5 \right triangle," as suggested in Fig. 20. If we try to place these p oints in one dimension, there must b e some stretching and shrinking of springs. The optimum con guration, also shown in Fig. 20, is when the springs of length 3 and 4 are compressed to 7/3 and 10/3, while the spring of length 5 is stretched to 17/3. In this con guration, the total energy of the system is (3 ^73 )^2 + (4 ^103 )^2 + (5 ^173 )^2 = 4 =3. 2

a

b

c b a

c

Figure 20: Optimal placement of three p oints in one dimension

8.2 Fastmap

Problem: multidimensional scaling requires at least O (n^2 ) time to handle n p oints, since we must compute all distances at least once | p erhaps more than once. Fastmap is a metho d for creating k pseudo-axes that can serve to place n p oints in a k -dim space in O (nk ) time. In outline, Fastmap picks k pairs of p oints (ai ; bi ), each of which pairs serves as the \ends" of one of the k axes of the k -dim space. Using the law of cosines, we can calculate the \pro jection" x of any p oint c onto the line ab, using only the distances b etween p oints, not any assumed co ordinates of these p oints in a plane. The diagram is shown in Fig. 21, and the formula is

x = D 2 (a; c) + D 2 (a; b) D 2 (b; c) 2 D (a; b)

a b

c

D(a,b)

x

D(a,c) D(b,c)

Figure 21: Computing the pro jection of p oint c onto line ab

Having picked a pair of p oints (a; b) as an axis, part of the distance b etween any two p oints c and d is accounted for by the pro jections of c and d onto line ab, and the remainder of the distance is in other dimensions. If the pro jections of c and d are x and y , resp ectively, then in the future (as we select other axes), the distance Dcur r ent (c; d) should b e related to the given distance function D by

D (^) cur^2 r ent (c; d) = D 2 (c; d) (x y )^2

The explanation is suggested by Fig. 22. Here, then, is the outline of the Fastmap algorithm. It computes for each p oint c, k pro jections, which we shall refer to as c(1)^ ; c(2)^ ; : : : ; c(k^ )^ onto the k axes, which are determined by pairs of p oints (a 1 ; b 1 ); (a 2 ; b 2 ); : : : ; (ak ; bk ). For i = 1 ; 2 ; : : : ; k do the following:

  1. Using the current distance Dcur r ent , Pick ai and bi , as follows:

(a) Pick a random p oint c. (b) Pick ai to b e the p oint as far as p ossible from c, using distance Dcur r ent. (c) Pick bi to b e the p oint as far as p ossible from ai.

(a) Use a k -means approach | merge until only k clusters remain. (b) Stop merging clusters when the only clusters that can result from merging fail to meet some criterion of compactness, e.g., the average distance of no des to their clustroid or centroid is to o high.

8.5 The GRGPF Algorithm

This algorithm assumes there is a distance measure D , but no Euclidean space. It also assumes that there is to o much data to t in main memory. The data structure it uses to store clusters is like an R-tree. No des of the tree are disk blo cks, and we store di erent things at leaf and interior no des:

 In leaf blo cks, we store cluster features that summarize a cluster in a manner similar to BFR. However, since there is no Euclidean space, the \features are somewhat di erent, as follows: (a) The numb er of p oints in the cluster, N. (b) The clustroid: that p oint in the cluster that minimizes the rowsum, i.e., the sum of the squares of the distances to the other p oints of the cluster. { If C is a cluster, C^ will denote its clustroid. { Thus, the rowsum of the clustroid is

P

X in C D^ (^ C^^ ;^ X^ ). { Notice that the rowsum of the clustroid is analogous to the statistic S U M S Q that was used in BFR. However, S U M S Q is relative to the origin of the Euclidean space, while GRGPF assumes no such space. The rowsum can b e used to compute a statistic, the radius of the cluster that is analogous to the standard deviation of a cluster in BFR. The formula is r adius =

p

r ow sum=N. (c) The p p oints in the cluster that are closest to the clustroid and their rowsums, for some chosen constant p. (d) The p p oints in the cluster that are farthest from the clustroid.  In interior no des, we keep samples of the clustroids of the clusters represented by the descendants of this tree no de. An e ort is made to keep the clusters in each subtree close. As in an R-tree, the interior no des thus inform ab out the approximate region in which clusters at their descendants are found. When we need to insert a p oint into some cluster, we start at the ro ot and pro ceed down the tree, cho osing only those paths along which a reasonably close cluster might b e found, judging from the samples at each interior no de.

8.6 Maintenance of Cluster Features by GRGPF

There is an initialization phase on a main-memory full of data, where the rst estimate of clusters is made, and the clusters themselves are arranged in a hierarchy corresp onding to the \R-tree." The need for this hierarchy was mentioned in item 8.5 ab ove.

We then examine all the other p oints and try to insert them into the existing clusters. The choice of clusters is reconsidered if there are to o many to t the representations in main memory, or if a cluster gets to o big (to o high a radius). There are many details ab out what happ ens when new p oints are added. Here are some of the key p oints:

(a) A new p oint X is placed in the cluster C such that D ( C^ ; X ) is a minimum. Use the samples at the interior no des of the tree to avoid searching the entire tree and all the clusters. (b) If p oint X is added to cluster C , we add to each of the 2 p + 1 rowsums maintained for that cluster (rowsums of C^ and the p closest and p furthest p oints) the square of the distance from that p oint to X. We also estimate the rowsum of X as N r 2 + N D ( C^ ; X ), where r is the radius of the cluster. The validity of this formula, as an approximation is, based on the prop erty of the \curse of dimensionality" we discussed in Section 7.2. That is, for each of the N p oints Y in the cluster, the distance b etween X and Y can b e measured by going to the clustroid (the term D ( C^ ; X )),

and then from the clustroid to Y (which is Y 's contribution to r ). If we assume that the lines (in a hyp othetical Euclidean space) from C^ to X and Y are likely to b e almost p erp endicular, then the formula is justi ed by the Pythagorean theorem. (c) We must consider the p ossibility that after adding X , cluster C now hasa di erent clustroid, which could b e X or one of the p p oints closest to C^. If, after accounting for X , one of these p oints has a lower rowsum, it b ecomes the clustroid. obviously, this pro cess cannot b e maintained inde nitely, since eventually the clustroid will migrate outside the p closest p oints. Thus, there may need to b e p erio dic recomputation of the cluster features for a cluster, which is p ossible | at the cost of disk I/O's | b ecause all p oints in the cluster are stored on disk, even if they are not in the main-memory tree that stores the cluster features and samples.

8.7 Splitting and Merging Clusters in GRGPF

Sometimes, the radius of the clustroid exceeds a given threshold, and the algorithm decides to split the cluster into two. This pro cess requires bringing the entire cluster into main memory and p erforming some split algorithm on just these p oints in memory.

An additional consequence is that the numb er of clusters in one leaf no de increases by 1. If the no de (disk blo ck) over ows, then it must b e split, as in a B-tree. That, in turn, may cause no des up the tree to b e split, and in the worst case, there is no ro om in main memory to hold the entire tree any more.

In that case, the solution is to raise the threshold that the radius of a cluster may have, and consider merging clusters throughout the tree. Supp ose we consider merging clusters Ci and Cj. We wish to avoid having to bring all of the p oints of these clusters into main memory, so we guess at the clustroid and the rowsums as follows:

(a) Assume that the clustroid of the combined cluster will b e one of the p oints furthest from the clustroid of either Ci or Cj. Rememb er that these p oints are all kept in the tree with their cluster features. (b) To decide on the new clustroid, we need to estimate the rowsum for each p oint X in either cluster. Supp ose for example that X is in Ci. Then we estimate:

Row sum(X ) = Row sumi (X ) + Nj

D 2 (X ; C^i ) + D 2 ( C^i ; C^j )

  • Row sumj ( C^j )

Here, Nj is the numb er of p oints in Cj , and as always, hats indicate the clustroid of a cluster. The rationale for the ab ove formula is that: i. The rst term represents the distances from X to all the no des in its cluster. ii. The middle term represents part of the paths from X to each p oint in Cj. We assume that the path starts out going from X to C^i , the clustroid of Ci. From there, it go es to C^j. Note that, by the \curse of dimensionality," we may assume that the lines from X to C^i and from C^i to C^j are \p erp endicular" and combine them using the Pythagorean theorem. iii. The nal term represents the comp onent of the paths from X to all the memb ers of Cj that continues after C^j is reached from X. Again, it is the \curse of dimensionality" assumption that lets us assume all the lines from C^j to memb ers of Cj are orthogonal to the line from C^i to C^j. (c) Having decided on the new clustroid, compute the rowsums for all p oints that we retain in the cluster features of the new cluster using the same formula as in (2).

8.8 CURE

We now return to clustering in a Euclidean space. The sp ecial problem solved by CURE is that when clusters are not neatly expressed as Gaussian noise around a central p oint (as BFR assume) many things can go wrong in a k -means approach.

Figure 24: Selecting sample p oints in CURE