15-505 Internet Search Technologies: Kamal Nigam
15-505 Internet Search Technologies: Kamal Nigam
Lecture 8: Clustering
Kamal Nigam
Slides adapted from Chris Manning, Prabhakar Raghavan, and Hinrich Schütze
(http://www-csli.stanford.edu/~hinrich/information-retrieval-book.html),
William Cohen (www.cs.cmu.edu/~wcohen/Matching-2.ppt), &
Ray Mooney (http://www.cs.utexas.edu/~mooney/cs391L/slides/clustering.ppt)
What is clustering?
Clustering: the process of grouping a set
of objects into classes of similar objects
Most common form of unsupervised
learning
Unsupervised learning = learning from
raw data, as opposed to supervised data
where a classification of examples is
given
Clustering
Clustering
Clustering – Reference matching
Fahlman, Scott & Lebiere, Christian (1989). The cascade-correlation
learning architecture. In Touretzky, D., editor, Advances in Neural
Information Processing Systems (volume 2), (pp. 524-532), San Mateo, CA.
Morgan Kaufmann.
Euclidean distance
What are we optimizing?
Given: Final number of clusters
Optimize:
“Tightness” of clusters
{average/min/max/} distance of points to each
other in the same cluster?
{average/min/max} distance of points to each
clusters center?
clusters
Finding the “right” number of clusters is part of
the problem
Given data, 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.
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
K not specified in advance
Given a clustering, define the Benefit
for a doc to be some inverse distance
to its centroid
Define the Total Benefit to be the sum
of the individual doc Benefits.
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.
Hierarchical Clustering
Build a tree-based hierarchical taxonomy
(dendrogram) from a set of documents.
animal
vertebrate invertebrate
Agglomerative (bottom-up):
Start with each document being a single cluster.
Eventually all documents belong to the same cluster.
Divisive (top-down):
Start with all documents belong to the same cluster.
Eventually each node forms a cluster on its own.
Could be a recursive application of k-means like algorithms
Does not require the number of clusters k in advance
Needs a termination/readout condition
Hierarchical Agglomerative Clustering (HAC)
• Clustering obtained
by cutting the
dendrogram at a
desired level: each
connected
component forms a
cluster.
Hierarchical Agglomerative
Clustering (HAC)
Starts with each doc in a separate
cluster
then repeatedly joins the closest pair
of clusters, until there is only one
cluster.
The history of merging forms a binary
tree or hierarchy.
How to measure distance of clusters??
Closest pair of clusters
Many variants to defining closest pair of clusters
Single-link
s W I L L I A M _ C O H E N
alignment
t W I L L L I A M _ C O H O N
op C C C C I C C C C C C C S C
cost 0 0 0 0 1 1 1 1 1 1 1 1 2 2
Levenstein distance - example
distance(“William Cohen”, “Willliam Cohon”)
s W I L L gap I A M _ C O H E N
alignment
t W I L L L I A M _ C O H O N
op C C C C I C C C C C C C S C
cost 0 0 0 0 1 1 1 1 1 1 1 1 2 2
Computing Levenstein distance
C O H E N
M 1 2 3 4 5
C 1 2 3 4 5
C 2 2 3 4 5
O 3 2 3 4 5
H 4 3 2 3 4
N 5 4 3 3 3 = D(s,t)
Computing Levenstein distance
C O H E N
A trace indicates M 2 3 4 5
1
where the min
value came from, C 1 2 3 4 5
and can be used to 3 3 4 5
C 2
find edit
operations and/or O 3 2 3 4 5
a best alignment
(may be more than 1) H 4 3 2 3 4
N 5 4 3 3 3
Large Clustering Problems
Many examples
Many clusters
Many dimensions
Example Domains
Text
Images
Protein structure
The Canopies Approach
Two distance metrics: cheap & expensive
First Pass
very inexpensive distance metric
create overlapping canopies
Second Pass
expensive, accurate distance metric
canopies determine which distances calculated
Illustrating Canopies
Overlapping Canopies
Creating canopies with
two thresholds
Put all points in D
Loop: tight
Pick a point X from D
Put points within
Kloose of X in canopy
loose
Using canopies with HAC
Calculate expensive
distances between points
in the same canopy
All other distances default
to infinity
Use finite distances and
iteratively merge closest
Inexpensive Distance Metric
for Text
Word-level matching (TFIDF)
Inexpensive using an inverted index
aardvark
ant
apple
...
...
zoo
Expensive Distance Metric for Text