clustering. what is clustering? clustering: the process of grouping a set of objects into classes of...

33
Clustering

Upload: philippa-allison

Post on 17-Jan-2016

237 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Clustering

Page 2: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

What is Clustering?• Clustering: the process of grouping a set of objects

into classes of similar objects– Documents within a cluster should be similar.– Documents from different clusters should be

dissimilar.

• The commonest form of unsupervised learning• Unsupervised learning = learning from raw data, as

opposed to supervised data where a classification of examples is given

– A common and important task that finds many applications in IR and other places

Ch. 16

Page 3: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

A data set with clear cluster structure

• How would you design an algorithm for finding the three clusters in this case?

Ch. 16

Page 4: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Applications of clustering in IR

• Whole corpus analysis/navigation– Better user interface: search without typing

• For improving recall in search applications– Better search results (like pseudo RF)

• For better navigation of search results– Effective “user recall” will be higher

• For speeding up vector space retrieval– Cluster-based retrieval gives faster search

Sec. 16.1

Page 5: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Yahoo! Hierarchy isn’t clustering but is the kind of output you want from clustering

dairy

crops

agronomyforestry

AI

HCI

craft

missions

botany

evolution

cell

magnetism

relativity

courses

agriculture biology physics CS space

... ... ...

www.yahoo.com/Science

... ...

Page 6: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Google News: automatic clustering gives an effective news presentation metaphor

Page 7: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Scatter/Gather: Cutting, Karger, and Pedersen

Page 8: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

For improving search recall• Cluster hypothesis - Documents in the same cluster behave

similarly with respect to relevance to information needs• Therefore, to improve search recall:

– Cluster docs in corpus a priori– When a query matches a doc D, also return other docs in the

cluster containing D• Example• – Medical documents• – Legal documents• – Financial documents

• if we do this: The query “car” will also return docs containing automobile– Because clustering grouped together docs containing car

with those containing automobile.

Sec. 16.1

Page 9: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Issues for clustering• Representation for clustering

– Document representation• Vector space? Normalization?

– Centroids aren’t length normalized

– Need a notion of similarity/distance

• How many clusters?– Fixed a priori?– Completely data driven?

• Avoid “trivial” clusters - too large or small– If a cluster's too large, then for navigation purposes you've wasted

an extra user click without whittling down the set of documents much.

Sec. 16.2

Page 10: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Notion of similarity/distance• Ideal: semantic similarity.

• Practical: term-statistical similarity– We will use cosine similarity.

– Docs as vectors.

– For many algorithms, easier to think in terms of a distance (rather than similarity) between docs.

– We will mostly speak of Euclidean distance• But real implementations use cosine similarity

Page 11: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Clustering Algorithms

• Flat algorithms– Usually start with a random (partial) partitioning– Refine it iteratively

• K means clustering• (Model based clustering)

• Hierarchical algorithms– Bottom-up, agglomerative– (Top-down, divisive)

Page 12: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Hard vs. soft clustering• Hard clustering: Each document belongs to exactly

one cluster– More common and easier to do

• Soft clustering: A document can belong to more than one cluster.– Makes more sense for applications like creating

browsable hierarchies

– You may want to put a pair of sneakers in two clusters: (i) sports apparel and (ii) shoes

– You can only do that with a soft clustering approach.

Page 13: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Partitioning Algorithms

• Partitioning method: Construct a partition of n documents into a set of K clusters

• Given: a set of documents and the number K

• Find: a partition of K clusters that optimizes the chosen partitioning criterion– Globally optimal

• Intractable for many objective functions• Ergo, exhaustively enumerate all partitions

– Effective heuristic methods: K-means and K-medoids algorithms

Page 14: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

K-Means

• Assumes documents are real-valued vectors.

• Clusters based on centroids (the center of gravity or mean) of points in a cluster, c:

• Reassignment of instances to clusters is based on distance to the current cluster centroids.– (Or one can equivalently phrase it in terms of

similarities)

cx

xc

||

1(c)μ

Sec. 16.4

Page 15: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

K-Means Algorithm

Page 16: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

K Means Example(K=2)

Pick seeds

Reassign clusters

Compute centroids

xx

Reassign clusters

xx xx Compute centroids

Reassign clusters

Converged!

Sec. 16.4

Page 17: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Termination conditions

• Several possibilities, e.g.,– A fixed number of iterations.

– Doc partition unchanged.

– Centroid positions don’t change.

Sec. 16.4

Page 18: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

How Many Clusters?

• Number of clusters K is given– Partition n docs into predetermined number of clusters

• Finding the “right” number of clusters is part of the problem– Given docs, partition into an “appropriate” number of

subsets.

– E.g., for query results - ideal value of K not known up front - though UI may impose limits.

• Can usually take an algorithm for one flavor and convert to the other.

Page 19: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

K not specified in advance

• Say, the results of a query.• Solve an optimization problem: penalize having lots

of clusters– application dependent, e.g., compressed summary

of search results list.• Tradeoff between having more clusters (better focus

within each cluster) and having too many clusters• Given a clustering, define the Benefit for a doc to be

the cosine similarity to its centroid• Define the Total Benefit to be the sum of the

individual doc Benefits.

Page 20: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Penalize lots of clusters

• For each cluster, we have a Cost C.• Thus for a clustering with K clusters, the Total Cost is

KC.• Define the Value of a clustering to be =

Total Benefit - Total Cost.

• Find the clustering of highest value, over all choices of K.– Total benefit increases with increasing K. But can stop

when it doesn’t increase by “much”. The Cost term enforces this.

Page 21: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Efficiency: Medoid As Cluster Representative

• The centroid does not have to be a document (typically won’t be).

• Medoid: A cluster representative that is one of the documents

• For example: the document closest to the centroid• One reason this is useful

– Consider the representative of a large cluster (>1000 documents)

– The centroid of this cluster will be a dense vector

– The medoid of this cluster will be a sparse vector

Page 22: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Hierarchical Clustering

• HC outputs a hierarchy, a structure that is more informative than the unstructured set of clusters returned by flat clustering.

• They are deterministic and doesn’t require prespecify the number of clusters.

• Build a tree-based hierarchical taxonomy (dendrogram) from a set of documents.

animal

vertebrate

fish reptile amphib. mammal worm insect crustacean

invertebrate

Page 23: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Two types of Hierarchal clustering

• HC algorithms are either top-down or bottom up.

• Aglommerative (bottom-up) methods start with each example in its own cluster and iteratively combine/merge them to form larger and larger clusters.

• Divisive (partitional, top-down) they requires a method for splitting a cluster. They separate all examples immediately into clusters. It proceeds by splitting clusters recursively until individual documents are not reached.

Page 24: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Dendrogram: Hierarchical Clustering

– Clustering obtained by cutting the dendrogram at a desired level: each connected component forms a cluster. HAC is visualized as dendrogram

Page 25: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Aglommerative (bottom-up) Clustering

• Merge the similar cluster into one.

• Assumes a similarity function for determining the similarity of two instances and two clusters.

• Starts with all instances in separate clusters and then repeatedly joins the two clusters that are most similar until there is only one cluster.

• The history of merging forms a binary tree or hierarchy.

Page 26: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

HAC Algorithm

Start with all instances in their own cluster.Until there is only one cluster: Among the current clusters, determine the two clusters, ci and cj, that are most similar. Replace ci and cj with a single cluster ci

cj

Page 27: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Pairing of Clusters• Variants to defining closest pair of clusters• Single-link

– Merge criteria is local (common feature)– Similarity of the most cosine-similar (single-link)– Pay attention solely to the area where two cluster come closest

to each other

• Complete-link– Similarity of two clusters is the similarity of their two most

dissimilar members– Merge criteria is non-local (distant feature)– Similarity of the “furthest” points, the least cosine-similar– Calculate sensitivity to outliers

Sec. 17.2

Page 28: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Single link – max similarity

Complete link – min similarity

Page 29: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Single Link Agglomerative Clustering

• Use maximum similarity of pairs:

• Can result in “straggly” (long and thin) clusters due to chaining effect.

• After merging ci and cj, the similarity of the resulting cluster to another cluster, ck, is:

),(max),(,

yxsimccsimji cycx

ji

)),(),,(max()),(( kjkikji ccsimccsimcccsim

Sec. 17.2

Page 30: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Single Link Example

Sec. 17.2

Page 31: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Complete Link• Use minimum similarity of pairs:

• Makes “tighter,” spherical clusters that are typically preferable.

• After merging ci and cj, the similarity of the resulting cluster to another cluster, ck, is:

),(min),(,

yxsimccsimji cycx

ji

)),(),,(min()),(( kjkikji ccsimccsimcccsim

Ci Cj Ck

Sec. 17.2

Page 32: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Complete Link Example

Sec. 17.2

Page 33: Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should

Divisive:Top – Down Clustering

• Start at the top with all documents in one cluster.

• The cluster is split using flat clustering algorithm (K-means).

• This procedure is applied recursively until each document is in its own singleton cluster.

• More complex but very efficient

• Take benefits from complete information about the global distribution when making top level partitioning decisions