Cluster analysis is a technique for multivariate analysis that assigns items to automatically created groups based on a calculation of the degree of association between items and groups. In the information retrieval (IR) field, cluster analysis has been used to create groups of documents with the goal of improving the efficiency and effectiveness of retrieval, or to determine the structure of the literature of a field. The terms in a document collection can also be clustered to show their relationships. The two main types of cluster analysis methods are the nonhierarchical, which divide a data set of *N *items into *M *clusters, and the hierarchical, which produce a nested data set in which pairs of items or clusters are successively linked. The nonhierarchical methods such as the single pass and reallocation methods are heuristic in nature and require less computation than the hierarchical methods. However, the hierarchical methods have usually been preferred for cluster-based document retrieval. The commonly used hierarchical methods, such as single link, complete link, group average link, and Ward's method, have high space and time requirements. In order to cluster the large data sets with high dimensionality that are typically found in IR applications, good algorithms (ideally *O*(*N*^{2}) time, *O*(*N*) space) must be found. Examples are the SLINK and minimal spanning tree algorithms for the single link method, the Voorhees algorithm for group average link, and the reciprocal nearest neighbor algorithm for Ward's method.

Cluster analysis is a statistical technique used to generate a category structure which fits a set of observations. The groups which are formed should have a high degree of association between members of the same group and a low degree between members of different groups (Anderberg 1973). While cluster analysis is sometimes referred to as automatic classification, this is not strictly accurate since the classes formed are not known prior to processing, as classification implies, but are defined by the items assigned to them.

Because cluster analysis is a technique for multivariate analysis that has application in many fields, it is supported by a number of software packages which are often available in academic and other computing environments. Most of the methods and some of the algorithms described in this chapter are found in statistical analysis packages such as SAS, SPSSX, and BMDP and cluster analysis packages such as CLUSTAN and CLUSTAR/CLUSTID. Brief descriptions and sources for these and other packages are provided by Romesburg (1984).

Selecting the attributes on which items are to be clustered and their representation.

Selecting an appropriate clustering method and similarity measure from those available .

Asessing the validity of the result obtained.

If the collection to be clustered is a dynamic one, the requirements for update must be considered.

In order to cluster the items in a data set, some means of quantifying the degree of association between them is required. This may be a distance measure, or a measure of similarity or dissimilarity. Some clustering methods have a theoretical requirement for use of a specific measure (Euclidean distance for Ward's method, for example), but more commonly the choice of measure is at the discretion of the researcher.

A variety of distance and similarity measures is given by Anderberg (1973), while those most suitable for comparing document vectors are discussed by Salton (1989). The Dice, Jaccard and cosine coefficients have the attractions of simplicity and normalization and have often been used for document clustering.

If binary term weights are used, the Dice Coefficient reduces to:

Many clustering methods are based on a pairwise coupling of the most similar documents or clusters, so that the similarity between every pair of points must be known. This necessitates the calculation of the *similarity matrix*; when the similarity measure is symmetric (*S _{ij }*=

for ( docno = 0; docno < n; docno++ )

{

for ( i = 0; i < doclength; i++ )

{

retrieve_inverted_list ( term[i] );

for ( j = 0; j < invlength; j++ ) counter[doc[j]]++;

}

for ( doc2 = 0; doc2 < n; doc2++ )

{

if (counter [doc2]) calc_similarity( docno, doc2 );

}

}

There are a very large number of ways of sorting *N* objects into *M* groups, a problem compounded by the fact that *M* is usually unknown. Most of the possible arrangements are of no interest; it is the role of a clustering method to identify a set of groups or cluster that reflects some underlying structure in the data. Moreover, there are many clustering methods available, which have differing theoretical or empirical bases and therefore produce different cluster structures. For a given clustering *method*, there may be a choice of clustering *algorithm* or means to implement the method. The choice of clustering method will determine the outcome, the choice of algorithm will determine the efficiency with which it is achieved. In this section, an overview of the clustering methods most used in information retrieval will be provided. The associated algorithms that are best suited to the processing of the large data sets found in information retrieval applications are discussed in sections 16.4 and 16.5.

In cases where the data set to be processed is very large, the resources required for cluster analysis may be considerable. A major component of the computation required is the calculation of the document-document or document-cluster similarity. The time requirement will be minimally *O*(*NM*), where *M* is the number of clusters, for the simpler reallocation methods; where the similarity matrix must be constructed, the proportionality is at least *N*^{2}. Most of the preferred clustering methods have time requirements of at least *O*(*N*^{2}). The storage requirement will be *O*(*N*) if the data set is stored, or *O*(*N*^{2}) if the similarity matrix is stored. For large *N* this may be unacceptable, and disk accesses may make processing time too large if the similarity matrix is stored on disk. An alternative is to recalculate the similarity matrix from the stored data whenever it is needed to identify the current most similar pair, but this increases the time requirement by a factor of *N*^{2}.

Clustering methods are usually categorized according to the type of cluster structure they produce. The simple *nonhierarchical* methods divide the data set of *N* objects into *M* clusters; where no overlap is allowed, these are known as partitioning methods. Each item has membership in the cluster with which it is most similar, and the cluster may be represented by a centroid or cluster representative that is indicative of the characteristics of the items it contains. The more complex *hierarchical* methods produce a nested data set in which pairs of items or clusters are successively linked until every item in the data set is connected. The hierarchical methods can be either *agglomerative*, with *N* - 1 pairwise joins beginning from an unclustered data set, or *divisive*, beginning with all objects in a single cluster and progressing through *N* - 1 divisions of some cluster into a smaller cluster. The divisive methods are less commonly used and few algorithms are available; only agglomerative methods will be discussed in this chapter.

The nonhierarchical methods are heuristic in nature, since a priori decisions about the number of clusters, cluster size, criterion for cluster membership, and form of cluster representation are required. Since the large number of possible divisions of *N* items into *M* clusters make an optimal solution impossible, the nonhierarchical methods attempt to find an approximation, usually by partitioning the data set in some way and then reallocating items until some criterion is optimized. The computational requirement *O*(*NM*) is much lower than for the hierarchical methods if *M* << *N*, so that large data sets can be partitioned. The nonhierarchical methods were used for most of the early work in document clustering when computational resources were limited; see for example work on the SMART project, described by Salton (1971).

Most of the early published work on cluster analysis employed hierarchical methods (Blashfield and Aldenderfer 1978), though this was not so in the IR field. With improvements in computer resources, the easy availability of software packages for cluster analysis, and improved algorithms, the last decade of work on clustering in IR retrieval has concentrated on the hierarchical agglomerative clustering methods (HACM, Willett [1988]).

The most commonly used hierarchical agglomerative clustering methods and their characteristics are:

**single link:** The single link method joins, at each step, the most similar pair of objects that are not yet in the same cluster. It has some attractive theoretical properties (Jardine and Sibson 1971) and can be implemented relatively efficiently, so it has been widely used. However, it has a tendency toward formation of long straggly clusters, or chaining, which makes it suitable for delineating ellipsoidal clusters but unsuitable for isolating spherical or poorly separated clusters.

**complete link:** The complete link method uses the least similar pair between each of two clusters to determine the intercluster similarity; it is called complete link because all entities in a cluster are linked to one another within some minimum similarity. Small, tightly bound clusters are characteristic of this method.

**group average link:** As the name implies, the group average link method uses the average values of the pairwise links within a cluster to determine similarity. All objects contribute to intercluster similarity, resulting in a structure intermediate between the loosely bound single link clusters and tightly bound complete link clusters. The group average method has ranked well in evaluative studies of clustering methods (Lorr 1983).

**Ward's method:** Ward's method is also known as the minimum variance method because it joins at each stage the cluster pair whose merger minimizes the increase in the total within-group error sum of squares, based on the Euclidean distance between centroids. It tends to produce homogeneous clusters and a symmetric hierarchy, and its definition of a cluster center of gravity provides a useful way of representing a cluster. Tests have shown it to be good at recovering cluster structure, though it is sensitive to outliers and poor at recovering elongated clusters (Lorr 1983).

The single pass method is particularly simple since it requires that the data set be processed only once. The general algorithm is as follows:

**1. **Assign the first document *D*_{1} as the representative for *C*_{1}**.**

**2. **For *D _{i},* calculate the similarity

**4. **If an item *D _{i}* remains to be clustered, return to step 2.

The reallocation methods operate by selecting some initial partition of the data set and then moving items from cluster to cluster to obtain an improved partition. Anderberg (1973) discusses some of the criteria that have been suggested to establish an initial partition and to monitor the improvement achieved by reallocation. A general algorithm is:

**1. **Select *M* cluster representatives or centroids.

**2. **For *i* = 1 to * N*, assign

**3. **For *j* = 1 to *M*, recalculate the cluster centroid *C _{j}*.

The single pass and reallocation methods were used in early work in cluster analysis in IR, such as the clustering experiments carried out in the SMART project (Salton 1971). Their time and storage requirements are much lower than those of the HACM and much larger data sets could be processed. With improved processing capability and more efficient hierarchical algorithms, the HACMs are now usually preferred in practice, and the nonhierarchical methods will not be considered further in this chapter.

All of the hierarchical agglomerative clustering methods can be described by a general algorithm:

**1. **Identify the two closest points and combine them in a cluster.

**2. **Identify and combine the next two closest points (treating existing clusters as points).

**3. **If more than one cluster remains, return to step 1.

*d _{Ci,j}c_{k} *=

This formula can be modified to accomodate a variety of HACM by choice of the values of , , and . The hierarchical clustering methods previously discussed are presented in Table 16.1 in the context of their Lance-Williams parameters and cluster centers.

The single link method merges at each stage the closest previously unlinked pair of points in the data set. Since the distance between two clusters is defined as the distance between the closest pair of points each of which is in one of the two clusters, no cluster centroid or representative is required, and there is no need to recalculate the similarity matrix during processing. This makes the method attractive both from a computational and a storage perspective, and it also has desirable mathematical properties (Jardine and Sibson 1971), so that it is one of the most widely used of the HACM.

Van Rijsbergen (1971) developed an algorithm to generate the single link hierarchy that allowed the similarity values to be presented in any order and therefore did not require the storage of the similarity matrix. It is *O *(*N ^{2}*) in time and

The SLINK algorithm (Sibson 1973) is optimally efficient, *O *(*N*^{2}) for computation and *O *(*N*) for time, and therefore suitable for large data sets. It is simply a sequence of operations by which a representation of the single link hierarchy can be recursively updated; the dendrogram is built by inserting one point at a time into the representation.

/* initialize pi and lambda for a single point representation */

pi [0] = 0;

lambda[0] = MAXINT;

/*iteratively add the remaining N-1 points to the hierarchy */

for (i = 1; i < N; i++)

{

pi [i] = i;

lambda[i] = MAXINT;

/* calculate and store a row of the distance matrix for i */

for (j = 0; j < i-1; j++) distance[j] =calc_distance(i,j);

for (j = 0; j < i-1; j++)

{

next = pi[j];

if (lambda[j] < distance[j])

distance[next] = min(distance[next],distance[j]);

else

{

distance[next] = min(lambda[j],distance[next]);

pi[j] = i;

lambda[j] = distance[j];

}

}

/* relabel clusters if necessary */

for (j = 0; j <i-1; j++)

{

next = pi [j];

if (lambda[next] < lambda [j])

pi[j] = i;

}

}

A minimal spanning tree (MST) is a tree linking *N* objects with *N* - 1 connections so that there are no loops and the sum of the *N* - 1 dissimilarities is minimized. It can be shown that all the information required to generate a single link hierarchy for a set of points is contained in their MST (Gower and Ross 1969). Once an MST has been constructed, the corresponding single link hierarchy can be generated in *O (N*^{2}) operations; or the data structures for the MST can be modified so that the hierarchy can be built simultaneously (Rohlf 1982).

Two fundamental construction principles for MSTs are:

**1. **Any isolated point can be connected to a nearest neighbor.

The Prim-Dijkstra algorithm (Dijkstra 1976) consists of a single application of principle 1, followed by *N* - 1 iterations of principle 2, so that the MST is grown by enlarging a single fragment:

**1. **Place an arbitrary point in the MST and connect its nearest neighbor to it.

**2. **Find the point not in the MST closest to any point in the MST and add it to the fragment.

**3. **If a point remains that is not in the fragment, return to step 2.

/* initialize lists */

for (i = 0; i < n; i++)

{

ndistance[i] = MAXINT;

notintree[i] = i;

}

/* arbitrarily place the Nth point in the MST */

lastpoint = n;

nt = n-1;

/* grow the tree an object at a time */

for ( i = 0; i < n-1;i++)

{

/*consider the lastpoint in the tree for the NN list */

for (j = 0; j < nt; j++)

{

D = calculate_distance(lastpoint, notintree[j]);

if (D < ndistance[j]

{

npoint[j] =lastpoint;

ndistance[j] = D;

}

}

/* find the unconnected point closest to a point in the */

/* tree */

nj = index_of_min(ndistance);

/* add this point to the MST; store this point and their */

/* clustering level */

lastpoint = notintree[nj];

store_in_MST ( lastpoint, npoint[nj], ndistance[nj]);

/* remove lastpoint from notintree list; */

/* close up npoint and ndistance lists */

notintree[nj] = nt;

npoint[nj] = npoint[nt];

ndistance[nj] =ndistance[nt];

nt = nt - 1;

}

}

The small, tightly bound clusters typical of the complete link method have performed well in comparative studies of document retrieval (Voorhees 1986a). Unfortunately, it is difficult to apply to large data sets since there does not seem to be an algorithm more effective than the stored data or stored matrix approach to the general HACM algorithm.

The best-known algorithm for implementing the complete link method is the CLINK algorithm developed by Defays (1977). It is presented in a form analogous to the SLINK algorithm, uses the same three arrays (*pi, lambda,* and *distance*), and like SLINK, produces output in the form of the pointer representation. Defays presents a CLINK subroutine which allows his algorithm to be incorporated into Sibson's original FORTRAN program for SLINK. CLINK is efficient, requiring *O (N*^{2}) time, *O (N*) space, but it does not seem to generate an exact hierarchy and has given unsatisfactory results in some information retrieval experiments (El-Hamdouchi and Willett 1989).

The Voorhees algorithm (1986b) for the complete link method has been used to cluster relatively large document collections with better retrieval results than the CLINK algorithm (El-Hamdouchi and Willett 1989). It is a variation on the sorted matrix approach, and is based on the fact that if the similarities between all pairs of documents are processed in descending order, two clusters of size *m _{i}* and

Because the similarity between two clusters is determined by the average value of all the pairwise links between points for which each is in one of the two clusters, no general *O (N*^{2}) time, *O (N*) space algorithm is known. The general HACM algorithm can be used, but with *O (N*^{3}) time for the stored data approach and *O (N*^{2}) storage for the stored matrix approach, implementation may be impractical for a large collection. However, a more efficient special case algorithm is available.

Ward's method (Ward 1963; Ward and Hook 1963) follows the general algorithm for the HACM, where the object/cluster pair joined at each stage is the one whose merger minimizes the increase in the total within-group squared deviation about the means, or variance. When two points *D _{i}* and

The mathematical properties of Ward's method make it a suitable candidate for a reciprocal nearest neighbor (RNN) algorithm (Murtaugh 1983, 1985). For any point or cluster, there exists a chain of nearest neighbors (NNs) so that

NN(i) = j; NN(j) = k; ...; NN(p) = q; NN(q) = p

**2. **Follow the NN chain from this point till an RNN pair is found.

**3. **Merge these two points and replace them with a single point.

As Dubes and Jain (1980, p. 179) point out:

Many evaluative studies have attempted to determine the "best" clustering method (Lorr 1983) by applying a range of clustering methods to test data sets and comparing the quality of the results, for example by using artificially created data structures, or comparing the cluster results to a classification established by experts in the field. Even under laboratory conditions it is difficult to evaluate clustering methods, since each method has different properties and strengths. The results of these studies do not suggest a single best method, though Ward's method, and in more recent studies, the group average method, have performed well. It is usually advisable to apply more than one clustering method and use some validation method to check the reliability of the resulting cluster structure.

Cluster validity procedures are used to verify whether the data structure produced by the clustering method can be used to provide statistical evidence of the phenomenon under study. Dubes and Jain (1980) survey the approaches that have been used, categorizing them on their ability to answer four questions: is the data matrix random? how well does a hierarchy fit a proximity matrix? is a partition valid? and which individual clusters appearing in a hierarchy are valid? Willett (1988) has reviewed the application of validation methods to clustering of document collections, primarily the application of the random graph hypothesis and the use of distortion measures.

An approach that is carried out prior to clustering is also potentially useful. Tests for *clustering tendency* attempt to determine whether worthwhile retrieval performance would be achieved by clustering a data set, before investing the computational resources which clustering the data set would entail. El-Hamdouchi and Willett (1987) describe three such tests. The *overlap test* is applied to a set of documents for which query-relevance judgments are available. All the relevant-relevant (RR) and relevant-nonrelevant (RNR) interdocument similarities are calculated for a given query, and the overlap (the fraction of the RR and RNR distributions that is common to both) is calculated. Collections with a low overlap value are expected to be better suited to clustering than those with high overlap values. Voorhees' *nearest neighbor test* considers, for each relevant document for a query, how many of its *n *nearest neighbors are also relevant; by averaging over all relevant documents for all queries in a test colleciton, a single indicator for a collection can be obtained. The *density test* is defined as the total number of postings in the document collection divided by the product of the number of documents and the number of terms that have been used for the indexing of those documents. It is particularly useful because it does not require any predetermined query-relevance data or any calculation of interdocument similarities. Of the three tests, the density test provided the best indication of actual retrieval performance from a clustered data set.

The goal of a hierarchical clustering process may be to partition the data set into some unknown number of clusters *M* (which may be visualized as drawing a horizontal line across the dendrogram at some clustering level). This requires the application of a *stopping rule*, a statistical test to predict the clustering level that will determine *M*. Milligan and Cooper (1985) evaluated and ranked 30 such rules, one or more of which is usually present in a software package for cluster analysis (though not necessarily those ranked highest by Milligan and Cooper).

In many information retrieval environments, the collection is dynamic, with new items being added on a regular basis, and, less frequently, old items withdrawn. Since clustering a large data set is resource-intensive, some mechanism for updating the cluster structure without the need to recluster the entire collection is desirable. Relatively little work has been done on methods for cluster maintenance (Can and Ozkarahan 1989), particularly for the hierarchical methods. In certain cases, update of the cluster structure is implicit in the clustering algorithm. This is true of both the van Rijsbergen and SLINK algorithms for the single link method, and the CLINK algorithm for the complete link method, all of which operate by iteratively inserting a document into an existing hierarchy.

Document clustering has been studied because of its potential for improving the efficiency of retrieval, for improving the effectiveness of retrieval, and because it provides an alternative to Boolean or best match retrieval. Initially the emphasis was on efficiency: document collections were partitioned, using nonhierarchical methods, and queries were matched against cluster centroids, which reduced the number of query-document comparisons that were necessary in a serial search. Studies of retrieval from partitioned document collections showed that though retrieval efficiency was achieved, there was a decrease in retrieval effectiveness (Salton 1971). Subsequent study has concentrated on the effectiveness of retrieval from hierarchically clustered document collections, based on the *cluster hypothesis*, which states that associations between documents convey information about the relevance of documents to requests (van Rijsbergen 1979).

There are several ways in which a query can be matched against the documents in a hierarchy (Willett 1988). A *top-down search* involves entering the tree at the root and matching the query against the cluster at each node, moving down the tree following the path of greater similarity. The search is terminated according to some criterion, for instance when the cluster size drops below the number of documents desired, or when the query-cluster similarity begins to decrease. A single cluster is retrieved when the search is terminated. Since it is difficult to adequately represent the clusters in the very large top-level clusters, a useful modification is to eliminate the top-level clusters by applying a threshold clustering level to the hierarchy to obtain a partition, and using the best of these mid-level clusters as the starting point for the top-down search. The top-down strategy has been shown to work well with the complete link method (Voorhees 1986a).

A *bottom-up search* begins with some document or cluster at the base of the tree and moves up until the retrieval criterion is satisfied; the beginning document may be an item known to be relevant prior to the search, or it can be obtained by a best match search of documents or lowest-level clusters. Comparative studies suggest that the bottom-up search gives the best results (apart from the complete link method), particularly when the search is limited to the bottom-level clusters (Willett 1988). Output may be based on retrieval of a single cluster, or the top-ranking clusters may be retrieved to produce a predetermined number of either documents or clusters; in the latter case, the documents retrieved may themselves be ranked against the query.

A simple retrieval mechanism is based on *nearest neighbor clusters*, that is, retrieving a document and that document most similar to it. Griffiths et al. (1984) determined that for a variety of test collections, search performance comparable to or better than that obtainable from nonclustered collections could be obtained using this method.

A centroid or cluster representative is a record that is used to represent the characteristics of the documents in a cluster. It is required in retrieval so that the degree of similarity between a query and a cluster can be determined; it is also needed in the nonhierarchical methods where document-cluster similarity must be determined in order to add documents to the most similar cluster. Ranks or frequencies have been used to weight terms in the representative; usually a threshold is applied to eliminate less significant terms and shorten the cluster representative. A binary representative may also be used, for example including a term if it occurs in more than *log _{2}m* documents in the cluster (Jardine and van Rijsbergen 1971).

ALDENDERFER, M. S., and R. K. BLASHFIELD. 1984. *Cluster Analysis*. Beverly Hills: Sage.

ANDERBERG, M. R., 1973. *Cluster Analysis for Applications*. New York: Academic.

DEFAYS, D. 1977. "AEfficient n Algorithm for a Complete Link Method." *Computer Journal*, 20, 364-66.

EVERITT, B. 1980. *Cluster Analysis*, 2nd ed. New York: Halsted.

HARTIGAN, J. A. 1975. *Clustering Algorithms*. New York: Wiley.

JARDINE, N., and R. SIBSON. 1971. *Mathematical Taxonomy*. London: Wiley.

KAUFMAN, L. 1990. *Finding Groups in Data: An Introduction to Cluster Analysis*. New York: Wiley.

ROMESBURG, H. C. 1984. *Cluster Analysis for Researchers*. Belmont, Calif.: Lifetime Learning.

SALTON, G., ed. 1971. *The SMART Retrieval System*. Englewood Cliffs, N.J.: Prentice Hall.

SALTON, G. 1989. *Automatic Text Processing*. Reading, Mass.: Addison-Wesley.

SPATH, H. 1985. *Cluster Dissection and Analysis*. Chichester: Ellis Horwood.

VAN RIJSBERGEN, C. J. 1979. *Information Retrieval*. London: Butterworths.