Clustering.

Slides:



Advertisements
Similar presentations
Clustering II.
Advertisements

Distance Measures Hierarchical Clustering k -Means Algorithms
SEEM Tutorial 4 – Clustering. 2 What is Cluster Analysis?  Finding groups of objects such that the objects in a group will be similar (or.
Clustering (2). Hierarchical Clustering Produces a set of nested clusters organized as a hierarchical tree Can be visualized as a dendrogram –A tree like.
Hierarchical Clustering
Unsupervised Learning
Cluster Analysis: Basic Concepts and Algorithms
1 CSE 980: Data Mining Lecture 16: Hierarchical Clustering.
Hierarchical Clustering. Produces a set of nested clusters organized as a hierarchical tree Can be visualized as a dendrogram – A tree-like diagram that.
Hierarchical Clustering, DBSCAN The EM Algorithm
Clustering Francisco Moreno Extractos de Mining of Massive Datasets
© 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.
Data Mining Cluster Analysis: Basic Concepts and Algorithms
More on Clustering Hierarchical Clustering to be discussed in Clustering Part2 DBSCAN will be used in programming project.
Mining of Massive Datasets Jure Leskovec, Anand Rajaraman, Jeff Ullman Stanford University Note to other teachers and users of these.
Clustering Shannon Quinn (with thanks to J. Leskovec, A. Rajaraman, and J. Ullman of Stanford University)
© 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.
1 Clustering Distance Measures Hierarchical Clustering k -Means Algorithms.
© University of Minnesota Data Mining for the Discovery of Ocean Climate Indices 1 CSci 8980: Data Mining (Fall 2002) Vipin Kumar Army High Performance.
1 Clustering Preliminaries Applications Euclidean/Non-Euclidean Spaces Distance Measures.
Data Mining Cluster Analysis: Advanced Concepts and Algorithms Lecture Notes for Chapter 9 Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach,
Distance Measures LS Families of Hash Functions S-Curves
Cluster Analysis.
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.
1 Clustering. 2 The Problem of Clustering uGiven a set of points, with a notion of distance between points, group the points into some number of clusters,
What is Cluster Analysis?
© University of Minnesota Data Mining for the Discovery of Ocean Climate Indices 1 CSci 8980: Data Mining (Fall 2002) Vipin Kumar Army High Performance.
Clustering Algorithms
CLUSTERING Eitan Lifshits Big Data Processing Seminar Prof. Amir Averbuch Mining of Massive Datasets, Jure Leskovec, Anand Rajaraman, Jeffery.
Clustering Ram Akella Lecture 6 February 23, & 280I University of California Berkeley Silicon Valley Center/SC.
Clustering Algorithms
Clustering. What is clustering? Grouping similar objects together and keeping dissimilar objects apart. In Information Retrieval, the cluster hypothesis.
DATA MINING LECTURE 8 Clustering The k-means algorithm
Clustering Unsupervised learning Generating “classes”
Clustering 1 Wu-Jun Li Department of Computer Science and Engineering Shanghai Jiao Tong University Lecture 8: Clustering Mining Massive Datasets.
Partitional and Hierarchical Based clustering Lecture 22 Based on Slides of Dr. Ikle & chapter 8 of Tan, Steinbach, Kumar.
CSE5334 DATA MINING CSE4334/5334 Data Mining, Fall 2014 Department of Computer Science and Engineering, University of Texas at Arlington Chengkai Li (Slides.
Clustering.
CS 8751 ML & KDDData Clustering1 Clustering Unsupervised learning Generating “classes” Distance/similarity measures Agglomerative methods Divisive methods.
Ch. Eick: Introduction to Hierarchical Clustering and DBSCAN 1 Remaining Lectures in Advanced Clustering and Outlier Detection 2.Advanced Classification.
Computational Biology Clustering Parts taken from Introduction to Data Mining by Tan, Steinbach, Kumar Lecture Slides Week 9.
Hierarchical Clustering Produces a set of nested clusters organized as a hierarchical tree Can be visualized as a dendrogram – A tree like diagram that.
Compiled By: Raj Gaurang Tiwari Assistant Professor SRMGPC, Lucknow Unsupervised Learning.
Data Mining Cluster Analysis: Basic Concepts and Algorithms Lecture Notes for Chapter 8 Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach,
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.
1 Clustering Distance Measures Hierarchical Clustering k -Means Algorithms.
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/ Data Mining: Cluster Analysis This lecture node is modified based on Lecture Notes for Chapter.
Clustering (1) Chapter 7. Outline Introduction Clustering Strategies The Curse of Dimensionality Hierarchical k-means.
Jeffrey D. Ullman Stanford University. 2  Generalized LSH is based on some kind of “distance” between points.  Similar points are “close.”  Example:
1 Clustering Preliminaries Applications Euclidean/Non-Euclidean Spaces Distance Measures.
Analysis of Massive Data Sets Prof. dr. sc. Siniša Srbljić Doc. dr. sc. Dejan Škvorc Doc. dr. sc. Ante Đerek Faculty of Electrical Engineering and Computing.
Clustering Shannon Quinn (with thanks to J. Leskovec, A. Rajaraman, and J. Ullman of Stanford University)
DATA MINING: CLUSTER ANALYSIS Instructor: Dr. Chun Yu School of Statistics Jiangxi University of Finance and Economics Fall 2015.
Data Mining Cluster Analysis: Basic Concepts and Algorithms Lecture Notes Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach, Kumar Introduction.
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 Classification and Clustering Techniques Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach, Kumar Introduction to Data Mining.
Data Mining: Basic Cluster Analysis
Clustering Hierarchical /Agglomerative and Point- Assignment Approaches Measures of “Goodness” for Clusters BFR Algorithm CURE Algorithm Jeffrey D. Ullman.
Clustering CSC 600: Data Mining Class 21.
Clustering Algorithms
Data Mining K-means Algorithm
Clustering CS246: Mining Massive Datasets
SEEM4630 Tutorial 3 – Clustering.
Hierarchical Clustering
Near Neighbor Search in High Dimensional Data (1)
Presentation transcript:

Clustering

The Problem of Clustering Given a set of points, with a notion of distance between points, group the points into some number of clusters, so that members of a cluster are in some sense as close to each other as possible. Inter-cluster distances are maximized Intra-cluster distances are minimized

A bit of history

Applications of Cluster Analysis Clustering for Understanding Group related documents for browsing Group genes and proteins that have similar functionality Group stocks with similar price fluctuations Segment customers into a small number of groups for additional analysis and marketing activities. Clustering for Summarization Reduce the size of large data sets Clustering precipitation in Australia

Examples Documents Represent a document by a vector (x1, x2,…, xk), where xi = 1 iff the i th word of a vocabulary appears in the document. Documents with similar sets of words may be about the same topic. DNAs Objects are sequences of {C,A,T,G}. Distance between sequences is edit distance, the minimum number of inserts and deletes needed to turn one into the other. Note there is a “distance,” but no convenient space in which points “live.”

Distance Measures Each clustering problem is based on some kind of “distance” between points. Two major classes of distance measure: Euclidean Non-Euclidean A Euclidean space has some number of real-valued dimensions. There is a notion of “average” of two points. A Euclidean distance is based on the locations of points in such a space. A Non-Euclidean distance is based on properties of points, but not their “location” in a space.

Axioms of a Distance Measure d is a distance measure if it is a function from pairs of points to real numbers such that: d(x,y) > 0. d(x,y) = 0 iff x = y. d(x,y) = d(y,x). d(x,y) < d(x,z) + d(z,y) (triangle inequality ).

Some Euclidean Distances L2 norm : d(x,y) = square root of the sum of the squares of the differences between x and y in each dimension. The most common notion of “distance.” L1 norm : sum of the differences in each dimension. Manhattan distance = distance if you had to travel along coordinates only. x = (5,5) y = (9,8) L2-norm: dist(x,y) = (42+32) = 5 L1-norm: 4+3 = 7 4 3 5

Non-Euclidean Distances Jaccard distance for sets = 1 minus ratio of sizes of intersection and union. Cosine distance = angle between vectors from the origin to the points in question. Edit distance = number of inserts and deletes to change one string into another.

Jaccard Distance for Sets (Bit-Vectors) Example: p1 = 10111; p2 = 10011. Size of intersection = 3; size of union = 4, Jaccard similarity (not distance) = 3/4. d(x,y) = 1 – (Jaccard similarity) = 1/4.

Why J.D. Is a Distance Measure d(x,x) = 0 because xx = xx. d(x,y) = d(y,x) because union and intersection are symmetric. d(x,y) > 0 because |xy| < |xy|. d(x,y) < d(x,z) + d(z,y) trickier... (1 - |x z|/|x z|) + (1 - |y z|/|y z|)  1 - |x y|/|x y| Remember: |a b|/|a b| = probability that minhash(a) = minhash(b) Thus, 1 - |a b|/|a b| = probability that minhash(a)  minhash(b). Claim: prob[mh(x)mh(y)]  prob[mh(x)mh(z)] + prob[mh(z)mh(y)] Proof: whenever mh(x)mh(y), at least one of mh(x)mh(z) and mh(z)mh(y) must be true.

Clustering with JD {a,b,d,e} {d,e,f} {a,b,c} {b,c,e,f} Similarity threshold = 1/3; distance < 2/3

Cosine Distance Think of a point as a vector from the origin (0,0,…,0) to its location. Two points’ vectors make an angle, whose cosine is the normalized dot-product of the vectors: p1.p2/|p2||p1|. Example: p1 = 00111; p2 = 10011. p1.p2 = 2; |p1| = |p2| = 3. cos() = 2/3;  is about 48 degrees. p1 p2 p1.p2  |p2| d (p1, p2) =  = arccos(p1.p2/|p2||p1|)

Why C.D. Is a Distance Measure d(x,x) = 0 because arccos(1) = 0. d(x,y) = d(y,x) by symmetry. d(x,y) > 0 because angles are chosen to be in the range 0 to 180 degrees. Triangle inequality: physical reasoning. If I rotate an angle from x to z and then from z to y, I can’t rotate less than from x to y.

Edit Distance The edit distance of two strings is the number of inserts and deletes of characters needed to turn one into the other. Equivalently: d(x,y) = |x| + |y| - 2|LCS(x,y)| LCS = longest common subsequence = any longest string obtained both by deleting from x and deleting from y. Example x = abcde ; y = bcduve. Turn x into y by deleting a, then inserting u and v after d. Edit distance = 3. Or, LCS(x,y) = bcde. Note: |x| + |y| - 2|LCS(x,y)| = 5 + 6 –2*4 = 3 = edit dist.

Why Edit Distance Is a Distance Measure d(x,x) = 0 because 0 edits suffice. d(x,y) = d(y,x) because insert/delete are inverses of each other. d(x,y) > 0: no notion of negative edits. Triangle inequality: changing x to z and then to y is one way to change x to y.

Hierarchical Clustering Produces a set of nested clusters organized as a hierarchical tree Can be visualized as a dendrogram A tree like diagram that records the sequences of merges or splits

Agglomerative Clustering Algorithm Compute the proximity matrix Let each data point be a cluster Repeat Merge the two closest clusters Update the proximity matrix Until only a single cluster remains Key operation is the computation of the proximity of two clusters Different approaches to defining the distance between clusters distinguish the different algorithms

Starting Situation Start with clusters of individual points and a proximity matrix p1 p3 p5 p4 p2 . . . . Proximity Matrix

Intermediate Situation After some merging steps, we have some clusters C2 C1 C3 C5 C4 C3 C4 Proximity Matrix C1 C5 C2

Intermediate Situation We want to merge the two closest clusters (C2 and C5) and update the proximity matrix. C2 C1 C3 C5 C4 C3 C4 Proximity Matrix C1 C5 C2

After Merging The question is “How do we update the proximity matrix?” C2 U C5 C1 C3 C4 C1 ? ? ? ? ? C2 U C5 C3 C3 ? C4 ? C4 Proximity Matrix C1 C2 U C5

How to Define Inter-Cluster Similarity p1 p3 p5 p4 p2 . . . . Similarity? MIN MAX Group Average Proximity Matrix

How to Define Inter-Cluster Similarity p1 p3 p5 p4 p2 . . . . MIN MAX Group Average Proximity Matrix

How to Define Inter-Cluster Similarity p1 p3 p5 p4 p2 . . . . MIN MAX Group Average Proximity Matrix

How to Define Inter-Cluster Similarity p1 p3 p5 p4 p2 . . . . MIN MAX Centroid distance Proximity Matrix

Cluster Similarity: MIN Similarity of two clusters is based on the two most similar (closest) points in the different clusters

Hierarchical Clustering: MIN 5 1 2 3 4 5 6 4 3 2 1 Nested Clusters Dendrogram

Strength of MIN Two Clusters Original Points Can handle non-globular shapes

Limitations of MIN Original Points Four clusters Three clusters: The yellow points got wrongly merged with the red ones, as opposed to the green one. Sensitive to noise and outliers

Cluster Similarity: MAX Similarity of two clusters is based on the two least similar (most distant) points in the different clusters

Hierarchical Clustering: MAX 5 4 1 2 3 4 5 6 2 3 1 Nested Clusters Dendrogram

Strengths of MAX Original Points Four clusters Three clusters: The yellow points get now merged with the green one. Less susceptible respect to noise and outliers

Limitations of MAX Two Clusters Original Points Tends to break large clusters

Cluster Similarity: Centroid distance Consider the distance between cluster centroids.

And in the Non-Euclidean Case? The only “locations” we can talk about are the points themselves. i.e., there is no “average” of two points. Approach 1: clustroid = point “closest” to other points. Treat clustroid as if it were centroid, when computing intercluster distances. “Closest” Point? Possible meanings: Smallest maximum distance to the other points. Smallest average distance to other points.

Example clustroid 1 2 6 4 3 clustroid 5 intercluster distance

k – Means Algorithm(s) Start by picking k, the number of clusters. Initialize clusters by picking one point per cluster. Pick one point at random, Then k -1 other points, each as far away as possible from the previous points each with the maximum possible minimum distance to the previously selected points. Example Suppose we pick A first. E is the furthest from A, so we pick it next. For the third point, the minimum distances to A or E are as follows B: 3.00, C: 2.83, D: 3.16, F: 2.00 The winner is D. Thus, D becomes the third seed.

Populating Clusters For each point, place it in the cluster whose current centroid it is nearest. After all points are assigned, fix the centroids of the k clusters. Optional: reassign all points to their closest centroid. Sometimes moves points between clusters. Repeat for a couple of rounds.

Example: Assigning Clusters Reassigned points Clusters after first round 2 4 x 6 7 5 x 3 1 8

Getting k Right Try different k, looking at the change in the average distance to centroid, as k increases. Average falls rapidly until right k, then changes little. k Average distance to centroid Best value of k

Example: Picking k x Too few; x xx x many long x x distances x x x to centroid. x x x x x x x x x x x x x x x x x x x x x x x x x x x

Example: Picking k x x xx x Just right; x x distances x x x rather short. x x x x x x x x x x x x x x x x x x x x x x x x x x

Example: Picking k x Too many; x xx x little improvement x x in average distance. x x x x x x x x x x x x x x x x x x x x x x x x x x x

BFR Algorithm BFR (Bradley-Fayyad-Reina) is a variant of k -means designed to handle very large (disk-resident) data sets. The goal is not to assign every point to a cluster, but to determine where the centroids of the clusters are. We can assign the points to clusters by another pass through the data, assigning each point to its nearest centroid and writing out the cluster number with the point. Points are read one main-memory-full at a time. Most points from previous memory loads are summarized by simple statistics. To begin, from the initial load we select the initial k centroids by some sensible approach.

Initialization: k -Means Possibilities include: Take a small random sample and cluster optimally. Take a sample; pick a random point, and then k – 1 more points, each as far from the previously selected points as possible.

Three Classes of Points The discard set : points close enough to a centroid to be summarized. The compression set : groups of points that are close together but not close to any centroid. They are summarized, but not assigned to a cluster. The retained set : isolated points.

Summarizing Sets of Points For each cluster, the discard set is summarized by: The number of points, N. The vector SUM, whose i th component is the sum of the coordinates of the points in the i th dimension. The vector SUMSQ: i th component = sum of squares of coordinates in i th dimension. 2d + 1 values represent any number of points. (d = number of dimensions). Averages in each dimension (centroid coordinates) can be calculated easily as SUMi /N. SUMi = i th component of SUM. Variance of a cluster’s discard set in dimension i can be computed by: (SUMSQi /N ) – (SUMi /N )2 And the standard deviation is the square root of that. The same statistics can represent any compression set.

“Galaxies” Picture Points in the RS Compressed sets. Their points are in the CS. Points in the RS A cluster. Its points are in the DS. The centroid

Processing a “Memory-Load” of Points Find those points that are “sufficiently close” to a cluster centroid; add those points to that cluster and the DS. Adjust statistics of the clusters to account for the new points. Use any main-memory clustering algorithm to cluster the remaining points and the old RS. Clusters go to the CS; outlying points to the RS. Consider merging compressed sets in the CS. If this is the last round, merge all compressed sets in the CS and all RS points into their nearest cluster.

A Few Details . . . How do we decide if a point is “close enough” to a cluster that we will add the point to that cluster? How do we decide whether two compressed sets deserve to be combined into one?

How Close is Close Enough? We need a way to decide whether to put a new point into a cluster. The Mahalanobis distance is less than a threshold. Mahalanobis distance: Normalized Euclidean distance. For point (x1,…,xk) and centroid (c1,…,ck): Normalize in each dimension: yi = (xi -ci)/i Take sum of the squares of the yi ’s. Take the square root.

Mahalanobis Distance – (2) If clusters are normally distributed in d dimensions, then after transformation, one standard deviation = d. i.e., 70% of the points of the cluster will have a Mahalanobis distance < d. Accept a point for a cluster if its M.D. is < some threshold, e.g. 3 standard deviations. If values are normally distributed, then very few of these values will be more than 3 standard deviations from the mean approximately one in a million will be that far from the mean). Thus, we would only reject one in a million points that belong in the cluster.

Picture: Equal M.D. Regions 2 

Should Two CS Subclusters Be Combined? Compute the variance of the combined subcluster. N, SUM, and SUMSQ allow us to make that calculation quickly. Combine if the variance is below some threshold.