Lecture 13: Clustering (continued) May 12, 2010

Slides:



Advertisements
Similar presentations
Lecture 15(Ch16): Clustering
Advertisements

Cluster Analysis: Basic Concepts and Algorithms
PARTITIONAL CLUSTERING
©2012 Paula Matuszek CSC 9010: Text Mining Applications: Document Clustering l Dr. Paula Matuszek l
Clustering Paolo Ferragina Dipartimento di Informatica Università di Pisa This is a mix of slides taken from several presentations, plus my touch !
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/ What is Cluster Analysis? l Finding groups of objects such that the objects in a group will.
Introduction to Bioinformatics
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/ What is Cluster Analysis? l Finding groups of objects such that the objects in a group will.
What is Cluster Analysis? Finding groups of objects such that the objects in a group will be similar (or related) to one another and different from (or.
Clustering II.
CS347 Lecture 8 May 7, 2001 ©Prabhakar Raghavan. Today’s topic Clustering documents.
Clustering… in General In vector space, clusters are vectors found within  of a cluster vector, with different techniques for determining the cluster.
© University of Minnesota Data Mining for the Discovery of Ocean Climate Indices 1 CSci 8980: Data Mining (Fall 2002) Vipin Kumar Army High Performance.
CS728 Web Clustering II Lecture 14. K-Means Assumes documents are real-valued vectors. Clusters based on centroids (aka the center of gravity or mean)
1 Text Clustering. 2 Clustering Partition unlabeled examples into disjoint subsets of clusters, such that: –Examples within a cluster are very similar.
Introduction to Information Retrieval Introduction to Information Retrieval Hinrich Schütze and Christina Lioma Lecture 16: Flat Clustering 1.
Cluster Analysis: Basic Concepts and Algorithms
Cluster Analysis (1).
What is Cluster Analysis?
Cluster Analysis CS240B Lecture notes based on those by © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004.
What is Cluster Analysis?
Unsupervised Learning: Clustering 1 Lecture 16: Clustering Web Search and Mining.
Clustering Ram Akella Lecture 6 February 23, & 280I University of California Berkeley Silicon Valley Center/SC.
Clustering Unsupervised learning Generating “classes”
CSC 4510 – Machine Learning Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Unsupervised Learning. CS583, Bing Liu, UIC 2 Supervised learning vs. unsupervised learning Supervised learning: discover patterns in the data that relate.
START OF DAY 8 Reading: Chap. 14. Midterm Go over questions General issues only Specific issues: visit with me Regrading may make your grade go up OR.
Text Clustering.
Clustering Supervised vs. Unsupervised Learning Examples of clustering in Web IR Characteristics of clustering Clustering algorithms Cluster Labeling 1.
tch?v=Y6ljFaKRTrI Fireflies.
Introduction to Information Retrieval Introduction to Information Retrieval CS276: Information Retrieval and Web Search Pandu Nayak and Prabhakar Raghavan.
ITCS 6265 Information Retrieval & Web Mining Lecture 15 Clustering.
Basic Machine Learning: Clustering CS 315 – Web Search and Data Mining 1.
1 Motivation Web query is usually two or three words long. –Prone to ambiguity –Example “keyboard” –Input device of computer –Musical instruments How can.
Introduction to Information Retrieval Introduction to Information Retrieval Modified from Stanford CS276 slides Chap. 16: Clustering.
Clustering Paolo Ferragina Dipartimento di Informatica Università di Pisa This is a mix of slides taken from several presentations, plus my touch !
UNSUPERVISED LEARNING David Kauchak CS 451 – Fall 2013.
Information Retrieval Lecture 6 Introduction to Information Retrieval (Manning et al. 2007) Chapter 16 For the MSc Computer Science Programme Dell Zhang.
Clustering I. 2 The Task Input: Collection of instances –No special class label attribute! Output: Clusters (Groups) of instances where members of a cluster.
Information Retrieval and Organisation Chapter 16 Flat Clustering Dell Zhang Birkbeck, University of London.
CS 8751 ML & KDDData Clustering1 Clustering Unsupervised learning Generating “classes” Distance/similarity measures Agglomerative methods Divisive methods.
Clustering. What is Clustering? Clustering: the process of grouping a set of objects into classes of similar objects –Documents within a cluster should.
CSCI 5417 Information Retrieval Systems Jim Martin Lecture 15 10/13/2011.
Clustering (Modified from Stanford CS276 Slides - Lecture 17 Clustering)
Today’s Topic: Clustering  Document clustering Motivations Document representations Success criteria  Clustering algorithms Partitional Hierarchical.
Lecture 12: Clustering May 5, Clustering (Ch 16 and 17)  Document clustering  Motivations  Document representations  Success criteria  Clustering.
Clustering/Cluster Analysis. What is Cluster Analysis? l Finding groups of objects such that the objects in a group will be similar (or related) to one.
Information Retrieval and Organisation Chapter 17 Hierarchical Clustering Dell Zhang Birkbeck, University of London.
Basic Machine Learning: Clustering CS 315 – Web Search and Data Mining 1.
Clustering Slides adapted from Chris Manning, Prabhakar Raghavan, and Hinrich Schütze (
1 CS 391L: Machine Learning Clustering Raymond J. Mooney University of Texas at Austin.
1 Machine Learning Lecture 9: Clustering Moshe Koppel Slides adapted from Raymond J. Mooney.
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/ Data Mining: Cluster Analysis This lecture node is modified based on Lecture Notes for Chapter.
Introduction to Information Retrieval Introduction to Information Retrieval Clustering Chris Manning, Pandu Nayak, and Prabhakar Raghavan.
DATA MINING: CLUSTER ANALYSIS Instructor: Dr. Chun Yu School of Statistics Jiangxi University of Finance and Economics Fall 2015.
Introduction to Information Retrieval Introduction to Information Retrieval CS276: Information Retrieval and Web Search Christopher Manning and Prabhakar.
Introduction to Information Retrieval Introduction to Information Retrieval CS276: Information Retrieval and Web Search Christopher Manning and Prabhakar.
CSE4334/5334 Data Mining Clustering. What is Cluster Analysis? Finding groups of objects such that the objects in a group will be similar (or related)
Data Mining and Text Mining. The Standard Data Mining process.
Hierarchical Clustering & Topic Models
Unsupervised Learning: Clustering
Prof. Paolo Ferragina, Algoritmi per "Information Retrieval"
Sampath Jayarathna Cal Poly Pomona
Unsupervised Learning: Clustering
Machine Learning Lecture 9: Clustering
Data Mining K-means Algorithm
本投影片修改自Introduction to Information Retrieval一書之投影片 Ch 16 & 17
CS 391L: Machine Learning Clustering
Text Categorization Berlin Chen 2003 Reference:
Presentation transcript:

Lecture 13: Clustering (continued) May 12, 2010

Announcements end of next class (May 19), at 8:45, take-home finals will be given. Due: May 26 at 6 PM project presentation – more in the next slide project report due: May 26 at the time of presentation.

Project Presentation – Details recommended format: slides with overhead projector (e.g. power-point) sample presentations – e-mailed and can be found under project link duration: 15 minutes should include: Problem statement Data set – size, how acquired, processing needed Algorithm – overview, time and space needs Result – performance, plots Challenges Summary and conclusion

K-Means Assumes documents are real-valued vectors. Sec. 16.4 K-Means Assumes documents are real-valued vectors. Clusters based on centroids (aka 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.

K-Means Algorithm Select K random docs {s1, s2,… sK} as seeds. Sec. 16.4 K-Means Algorithm Select K random docs {s1, s2,… sK} as seeds. Until clustering converges (or other stopping criterion): for each doc di: Assign di to the cluster cj such that dist(xi, sj) is minimal. (Next, update the seeds to the centroid of each cluster) for each cluster cj sj = (cj)

More formal description of algorithm

K Means Example (K=2) Pick seeds Reassign clusters Compute centroids Sec. 16.4 K Means Example (K=2) Pick seeds Reassign clusters Compute centroids x Reassign clusters x Compute centroids Reassign clusters Converged!

Termination conditions Sec. 16.4 Termination conditions Several possibilities, e.g., A fixed number of iterations. Doc partition unchanged. Centroid positions don’t change. Does this mean that the docs in a cluster are unchanged?

Convergence Why should the K-means algorithm ever reach a fixed point? Sec. 16.4 Convergence Why should the K-means algorithm ever reach a fixed point? A state in which clusters don’t change. K-means is a special case of a general procedure known as the Expectation Maximization (EM) algorithm. EM is known to converge. Number of iterations could be large. But in practice usually isn’t

Convergence of K-Means Sec. 16.4 Convergence of K-Means Define goodness measure of cluster k as sum of squared distances from cluster centroid: Gk = Σi (di – ck)2 (sum over all di in cluster k) G = Σk Gk Reassignment monotonically decreases G since each vector is assigned to the closest centroid.

Convergence of K-Means Sec. 16.4 Convergence of K-Means Recomputation monotonically decreases each Gk since (mk is number of members in cluster k): Σ (di – a)2 reaches minimum for: Σ –2(di – a) = 0 Σ di = Σ a mK a = Σ di a = (1/ mk) Σ di = ck K-means typically converges quickly

Sec. 16.4 Time Complexity Computing distance between two docs is O(M) where M is the dimensionality of the vectors. Reassigning clusters: O(KN) distance computations, or O(KNM). Computing centroids: Each doc gets added once to some centroid: O(NM). Assume these two steps are each done once for I iterations. Total time = O(IKNM). However, it is not clear how to bound I unless it is forced externally.

Seed Choice Results can vary based on random seed selection. Sec. 16.4 Seed Choice Results can vary based on random seed selection. Some seeds can result in poor convergence rate, or convergence to sub-optimal clusters. Select good seeds using a heuristic (e.g., doc least similar to any existing mean) Try out multiple starting points Initialize with the results of another method. Example showing sensitivity to seeds In the above, if you start with B and E as centroids you converge to {A,B,C} and {D,E,F} If you start with D and F you converge to {A,B,D,E} {C,F}

Two different K-means Clusterings Original Points Optimal Clustering Sub-optimal Clustering

Problem with Selecting Initial centroids If there are K ‘real’ clusters then the chance of selecting one centroid from each cluster is small. Chance is relatively small when K is large If clusters are the same size, n, then For example, if K = 10, then probability = 10!/1010 = 0.00036 Sometimes the initial centroids will readjust themselves in ‘right’ way, and sometimes they don’t

Initial Centroids not well chosen

A seemingly better initial choice

Solutions to Initial Centroids Problem Multiple runs Helps, but probability is not on your side Sample and use hierarchical clustering to determine initial centroids Select more than k initial centroids and then select among these initial centroids Select most widely separated Postprocessing Bisecting K-means Not as susceptible to initialization issues

Evaluating K-means Clusters Most common measure is Sum of Squared Error (SSE) For each point, the error is the distance to the nearest cluster To get SSE, we square these errors and sum them. x is a data point in cluster Ci and mi is the representative point for cluster Ci can show that mi corresponds to the center (mean) of the cluster Given two clusters, we can choose the one with the smallest error One easy way to reduce SSE is to increase K, the number of clusters A good clustering with smaller K can have a lower SSE than a poor clustering with higher K

K-means: issues, variations, etc. Sec. 16.4 K-means: issues, variations, etc. Recomputing the centroid after every assignment (rather than after all points are re-assigned) can improve speed of convergence of K-means. Assumes clusters are spherical in vector space Sensitive to coordinate changes, weighting etc. Disjoint and exhaustive Doesn’t have a notion of “outliers” by default But can add outlier filtering

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.

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 the cosine similarity 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.

Error as a function of k

Pre-processing and Post-processing Normalize the data Eliminate outliers Post-processing Eliminate small clusters that may represent outliers Split ‘loose’ clusters, i.e., clusters with relatively high SSE Merge clusters that are ‘close’ and that have relatively low SSE Can use these steps during the clustering process

Limitations of K-means: Non-globular Shapes Original Points K-means (2 Clusters)

Overcoming K-means Limitations Original Points K-means Clusters One solution is to use many clusters. Find parts of clusters, but need to put together.

Overcoming K-means Limitations Original Points K-means Clusters

Overcoming K-means Limitations Original Points K-means Clusters

Hierarchical Clustering Build a tree-based hierarchical taxonomy (dendrogram) from a set of documents. One approach: recursive application of a partitional clustering algorithm. animal vertebrate fish reptile amphib. mammal worm insect crustacean invertebrate

Dendrogram: Hierarchical Clustering Clustering obtained by cutting the dendrogram at a desired level: each connected component forms a cluster.

Hierarchical Agglomerative Clustering Sec. 17.1 Hierarchical Agglomerative Clustering 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.

Closest pair of clusters Sec. 17.2 Closest pair of clusters Many variants to defining closest pair of clusters Single-link Similarity of the most cosine-similar (single-link) Complete-link Similarity of the “furthest” points, the least cosine-similar Centroid Clusters whose centroids (centers of gravity) are the most cosine-similar Average-link Average cosine between pairs of elements

Single Link Agglomerative Clustering Sec. 17.2 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:

Sec. 17.2 Single Link Example

Complete Link Use minimum similarity of pairs: Sec. 17.2 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: Ci Cj Ck

Sec. 17.2 Complete Link Example

Simple hierarchical clustering algorithm

Computational Complexity Sec. 17.2.1 Computational Complexity In the first iteration, all HAC methods need to compute similarity of all pairs of N initial instances, which is O(N2). In each of the subsequent N2 merging iterations, compute the distance between the most recently created cluster and all other existing clusters. In order to maintain an overall O(N2) performance, computing similarity to each other cluster must be done in constant time. Often O(N3) if done naively or O(N2 log N) if done more cleverly

Efficient hierarchical clustering algorithm

Efficient single-link clustering algorithm

Sec. 17.3 Group Average Similarity of two clusters = average similarity of all pairs within merged cluster. Compromise between single and complete link. Two options: Averaged across all ordered pairs in the merged cluster Averaged over all pairs between the two original clusters No clear difference in efficacy

Computing Group Average Similarity Sec. 17.3 Computing Group Average Similarity Always maintain sum of vectors in each cluster. Compute similarity of clusters in constant time:

What Is A Good Clustering? Sec. 16.3 What Is A Good Clustering? Internal criterion: A good clustering will produce high quality clusters in which: the intra-class (that is, intra-cluster) similarity is high the inter-class similarity is low The measured quality of a clustering depends on both the document representation and the similarity measure used

External criteria for clustering quality Sec. 16.3 External criteria for clustering quality Quality measured by its ability to discover some or all of the hidden patterns or latent classes in gold standard data Assesses a clustering with respect to ground truth. (requires labeled data) Assume documents with C gold standard classes, while our clustering algorithms produce K clusters, ω1, ω2, …, ωK with ni members.

External Evaluation of Cluster Quality Sec. 16.3 External Evaluation of Cluster Quality Simple measure: purity, the ratio between the dominant class in the cluster πi and the size of cluster ωi Biased because having n clusters maximizes purity Others are entropy of classes in clusters (or mutual information between classes and clusters)

Purity example                  Cluster I Cluster II Sec. 16.3 Purity example                  Cluster I Cluster II Cluster III Cluster I: Purity = 1/6 (max(5, 1, 0)) = 5/6 Cluster II: Purity = 1/6 (max(1, 4, 1)) = 4/6 Cluster III: Purity = 1/5 (max(2, 0, 3)) = 3/5

Rand Index measures between pair decisions Sec. 16.3 Rand Index measures between pair decisions Here RI = 0.68 Number of points Same Cluster in clustering Different Clusters in clustering Same class in ground truth 20 24 Different classes in ground truth 72

Rand index and Cluster F-measure Sec. 16.3 Rand index and Cluster F-measure Compare with standard Precision and Recall: People also define and use a cluster F-measure, which is probably a better measure.

An application of clustering Example: Color quantization of Images Problem Convert a 24 bit RGB image into a indexed image with a palette of K colors. Solution The (r, g, b) values of the pixels are the data points xi The (r, g, b) values of the K palette colors are the centroids wk. Initialize the wk with the color of random pixels. Perform one pass of k-means algorithm. Each cluster is assigned one color.

Image Examples Original pictures segmented pictures Mnp: 30, percent 0.05, cluster number 4 Mnp : 20, percent 0.05, cluster number 7 Project by Qifong Xu, Penn

Image examples 2 Original pictures Segmented pictures Mnp: 10, percent 0.05, cluster number: 9 Mnp: 50, percent 0.05, cluster number: 3

Effect of cluster size Original picture Mnp:10, cluster number: 15

Image clustering in archeology Angkor Wat temple Angkor Wat contains a gallery of 2000 women. what facial types are represented in these portraits? A problem being solved by Prof. Anil Jain of MSU using clustering.

summary In clustering, clusters are inferred from the data without human input (unsupervised learning) There are many ways of influencing the outcome of clustering (with user input): number of clusters, similarity measure, choice of features. Many applications including text clustering, grouping genes/species, image processing/vision etc.