Full Transcript

CSE5DMI WEEK 09 latrobe.edu.au Cluster Analysis Cluster analysis divides data into groups (clusters) that are meaningful, useful, or both. Clustering for Understanding (Meaningful) Clusters are potential classes Cluster analysis is the study of techniques for automatically finding classes. Exam...

CSE5DMI WEEK 09 latrobe.edu.au Cluster Analysis Cluster analysis divides data into groups (clusters) that are meaningful, useful, or both. Clustering for Understanding (Meaningful) Clusters are potential classes Cluster analysis is the study of techniques for automatically finding classes. Examples: Biology, Information Retrieval, Business, Psychology & Medicine Clustering for Utility Clusters are cluster prototypes (representative of the data objects) Cluster analysis is the study of techniques for finding the most representative cluster prototypes. Examples: Efficiently Finding Nearest Neighbours, Summarisation, Compression What is Cluster Analysis? Given a set of objects, place them in groups such that the objects in a group are similar (or related) to one another and different from (or unrelated to) the objects in other groups Applications of Cluster Analysis Understanding Group related documents for browsing, group genes and proteins that have similar functionality, or group stocks with similar price fluctuations Summarization Reduce the size of large data sets Compression Images, Audio, Video Notion of a Cluster can be Ambiguous How many clusters? Six Clusters Two Clusters Four Clusters Types of Clusterings A clustering is a set of clusters Important distinction between hierarchical and partitional sets of clusters Partitional Clustering A division of data objects into non-overlapping subsets (clusters) Hierarchical clustering A set of nested clusters organized as a hierarchical tree Partitional Clustering (a) (b) (c) (d) Hierarchical Clustering p1 p2 p3 p4 Traditional Hierarchical Clustering Traditional Dendrogram p1 p2 p3 p4 Non-traditional Hierarchical Clustering Non-traditional Dendrogram Other Distinctions Between Sets of Clusters Exclusive versus non-exclusive In non-exclusive clusterings, points may belong to multiple clusters. Can belong to multiple classes or could be ‘border’ points – Fuzzy clustering (one type of non-exclusive) In fuzzy clustering, a point belongs to every cluster with some weight between 0 and 1 Weights must sum to 1 Probabilistic clustering has similar characteristics Partial versus complete In some cases, we only want to cluster some of the data Types of Clusters Well-separated clusters Prototype-based clusters Contiguity-based clusters Density-based clusters Described by an Objective Function Types of Clusters: Well-Separated Well-Separated Clusters: A cluster is a set of points such that any point in a cluster is closer (or more similar) to every other point in the cluster than to any point not in the cluster. 3 well-separated clusters Types of Clusters: Contiguity-Based Contiguous Cluster (Nearest neighbor or Transitive) – A cluster is a set of points such that a point in a cluster is closer (or more similar) to one or more other points in the cluster than to any point not in the cluster. 8 contiguous clusters Types of Clusters: Density-Based Density-based A cluster is a dense region of points, which is separated by low-density regions, from other regions of high density. Used when the clusters are irregular or intertwined, and when noise and outliers are present. 6 Density-based clusters Clustering Algorithms K-means And its variants Hierarchical clustering Density-based clustering K-means Clustering Partitional clustering approach Number of clusters, K, must be specified Each cluster is associated with a centroid (center point) Each point is assigned to the cluster with the closest centroid The basic algorithm is very simple Iteration 6 3 2.5 2 1.5 1 0.5 0 Slide -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x Iteration 1 3 Iteration 2 3 Iteration 3 3 2.5 2.5 2.5 2 2 2 1.5 1.5 1.5 1 1 1 0.5 0.5 0.5 0 0 0 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x Iteration 4 3 Iteration 5 3 Iteration 6 3 2.5 2.5 2.5 2 2 2 1.5 1.5 1.5 1 1 1 0.5 0.5 0.5 0 0 0 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x K-means Clustering – Details Simple iterative algorithm. Choose initial centroids; repeat {assign each point to a nearest centroid; re-compute cluster centroids} until centroids stop changing. Initial centroids are often chosen randomly. Clusters produced can vary from one run to another The centroid is (typically) the mean of the points in the cluster, but other definitions are possible. K-means will converge for common proximity measures with appropriately defined centroid. Most of the convergence happens in the first few iterations. Often the stopping condition is changed to ‘Until relatively few points change clusters’ Complexity is O (n * K * I * d) n = number of points, K = number of clusters, I = number of iterations, d = number of attributes K-means Objective Function A common objective function (used with Euclidean distance measure) is Sum of Squared Error (SSE) For each point, the error is the distance to the nearest cluster center To get SSE, we square these errors and sum them. K SSE 2 i=1 x∈Ci x is a data point in cluster Ci and mi is the centroid (mean) for cluster Ci SSE improves in each iteration of K-means until it reaches a local or global minima. Given two different sets of clusters, for two different runs of K-means, 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 Two different K-means Clusterings 3 2.5 2 Original Points 1.5 1 0.5 0 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x 3 3 2.5 2.5 2 2 1.5 1.5 1 1 0.5 0.5 0 0 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x Optimal Clustering -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x Sub-optimal Clustering Importance of Choosing Initial Centroids Iteration 5 3 2.5 2 1.5 1 0.5 0 Slide 21 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x Importance of Choosing Initial Centroids Iteration 2 3 3 2.5 2.5 2 2 1.5 1.5 1 1 0.5 0.5 0 0 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x 3 2.5 2 1.5 1 0.5 0 Importance of Choosing Initial Centroids Depending on the choice of initial centroids, B and C may get merged or remain separate Problems with Selecting Initial Points 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 Consider an example of five pairs of clusters 10 Clusters Example Starting with two initial centroids in one cluster of each pair of clusters 10 Clusters Example Iteration 1 8 6 4 2 0 -2 -4 -6 0 5 10 15 20 x Iteration 3 8 6 4 2 0 -2 -4 -6 0 5 10 15 20 x Iteration 2 8 6 4 2 0 -2 -4 -6 0 5 10 15 20 x Iteration 4 8 6 4 2 0 -2 -4 -6 0 5 10 15 20 x Starting with two initial centroids in one cluster of each pair of clusters 10 Clusters Example Starting with some pairs of clusters having three initial centroids, while other have only one. 10 Clusters Example Iteration 1 8 6 4 2 0 -2 -4 -6 0 5 10 15 20 Iteration 2 8 6 4 2 0 -2 -4 -6 0 5 10 15 20 Starting with some pairs of clusters having three initial centroids, while other have only one. Solutions to Initial Centroids Problem Multiple runs Helps, but probability is not on your side Use some strategy to select the k initial centroids and then select among these initial centroids Select most widely separated K-means++ is a robust way of doing this selection Use hierarchical clustering to determine initial centroids Bisecting K-means Not as susceptible to initialization issues Approach that speeds up K-means by reducing the number of similarities computed Bisecting K-Means Algorithm Bisecting K-means algorithm is a straightforward extension of the basic K-means algorithm To obtain K clusters: Split the set of all points into two clusters Select one of those two clusters to split Repeat steps 1 & 2 Select the next cluster Repeat steps 1 & 2 Stop when K clusters are obtained. Bisecting K-Means Algorithm You obtain hierarchical clustering by recording the sequence of clusterings. Final set of clusters reaches global minimum unlike K-means algorithm. Bisecting K-Means Algorithm Bisecting K-means has less trouble with initialization because it performs several trial bisections and takes the one with the lowest SSE, and because there are only two centroids at each step. Limitations of K-means K-means has problems when clusters are of differing Sizes Densities Non-globular shapes K-means has problems when the data contains outliers. One possible solution is to remove outliers before clustering Limitations of K-means: Differing Sizes Original Points K-means (3 Clusters) Limitations of K-means: Differing Density Original Points K-means (3 Clusters) 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 find a large number of clusters such that each of them represents a part of a natural cluster. But these small clusters need to be put together in a post-processing step. Overcoming K-means Limitations Original Points K-means Clusters One solution is to find a large number of clusters such that each of them represents a part of a natural cluster. But these small clusters need to be put together in a post-processing step. Overcoming K-means Limitations Original Points K-means Clusters One solution is to find a large number of clusters such that each of them represents a part of a natural cluster. But these small clusters need to be put together in a post-processing step. Thank you latíobe.edu.au La ľíobe Univeísity CRICOS Píovideí Code Numbeí 00115M © Copyíight La ľíobe Univeísity 2018 CSE5DMI WEEK 10 latrobe.edu.au Announcement Assignment-1 Marks Released 10 working days to request a review of marks Assessment Policy on LMS Final Exam Date (9th November 2023 2pm) Quick review: Week 9 Clustering basics K-means Today 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 displays the cluster-subcluster relationships and the order in which the clusters are merged or split. Strengths of Hierarchical Clustering Do not have to assume any particular number of clusters Any desired number of clusters can be obtained by ‘cutting’ the dendrogram at the proper level They may correspond to meaningful taxonomies Example in biological sciences (e.g., animal kingdom, phylogeny reconstruction, …) Hierarchical Clustering Two main types of hierarchical clustering Agglomerative: Start with the points as individual clusters At each step, merge the closest pair of clusters until only one cluster (or k clusters) left Divisive: Start with one, all-inclusive cluster At each step, split a cluster until each cluster contains an individual point (or there are k clusters) Traditional hierarchical algorithms use a similarity or distance matrix Merge or split one cluster at a time Agglomerative Clustering Algorithm Key Idea: Successively merge closest clusters Basic 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 Steps 1 and 2 Start with clusters of individual points and a proximity matrix . . . . Proximity Matrix ... p1 p2 p3 p4 p9 p10 p11 p12 Intermediate Situation After some merging steps, we have some clusters Proximity Matrix ... Step 4 We want to merge the two closest clusters (C2 and C5) and update the proximity matrix. Proximity Matrix Step 5 The question is “How do we update the proximity matrix?” C2 U C2 U Proximity Matrix MIN How to Define Inter-Cluster Distance . . Similarity? MAX Group Average Distance Between Centroids Other methods driven by an objective function Ward’s Method uses squared error . . Proximity Matrix MIN How to Define Inter-Cluster Similarity . . MAX Group Average Distance Between Centroids Other methods driven by an objective function Ward’s Method uses squared error . . Proximity Matrix MIN How to Define Inter-Cluster Similarity . . MAX Group Average Distance Between Centroids Other methods driven by an objective function Ward’s Method uses squared error . . Proximity Matrix MIN How to Define Inter-Cluster Similarity . . MAX Group Average Distance Between Centroids Other methods driven by an objective function Ward’s Method uses squared error . . Proximity Matrix MIN How to Define Inter-Cluster Similarity . . MAX Group Average Distance Between Centroids Other methods driven by an objective function Ward’s Method uses squared error . . Proximity Matrix MIN or Single Link Proximity of two clusters is based on the two closest points in the different clusters Determined by one pair of points, i.e., by one link in the proximity graph Example: Distance Matrix: Hierarchical Clustering: MIN 0.2 0.15 0.1 0.05 0 3 6 2 5 4 1 Nested Clusters Dendrogram Strength of MIN Original Points Six Clusters Can handle non-elliptical shapes Original Points Limitations of MIN Two Clusters Sensitive to noise Three Clusters MAX or Complete Linkage Proximity of two clusters is based on the two most distant points in the different clusters – Determined by all pairs of points in the two clusters Distance Matrix: Hierarchical Clustering: MAX 0.4 0.35 0.3 0.25 0.2 0.15 0.1 0.05 0 3 6 4 1 2 5 Nested Clusters Dendrogram Strength of MAX Original Points Two Clusters Less susceptible to noise Limitations of MAX Original Points Two Clusters Tends to break large clusters Biased towards globular clusters Group Average Proximity of two clusters is the average of pairwise proximity between points in the two clusters. proximity(Cluster , Cluster ) = ∑proximity(pi ,pj ) pi∈Clusteri pj∈Clusterj i j |Cluster |×|Cluster | i j Distance Matrix: Hierarchical Clustering: Group Average Nested Clusters Dendrogram Hierarchical Clustering: Group Average Compromise between Single and Complete Link Strengths Less susceptible to noise Limitations Biased towards globular clusters Cluster Similarity: Ward’s Method Similarity of two clusters is based on the increase in squared error when two clusters are merged Similar to group average if distance between points is distance squared Less susceptible to noise Biased towards globular clusters Hierarchical analog of K-means Can be used to initialize K-means Hierarchical Clustering: Comparison MIN MAX Ward’s Method Group Average 5 4 1 2 5 2 3 6 1 4 3 Hierarchical Clustering: Problems and Limitations Once a decision is made to combine two clusters, it cannot be undone No global objective function is directly minimized Different schemes have problems with one or more of the following: Sensitivity to noise Difficulty handling clusters of different sizes and non-globular shapes Breaking large clusters Summary Hierarchical clustering Agglomerative clustering algorithm Inter-cluster similarity measurement Advantages and challenges Thank you latíobe.edu.au La ľíobe Univeísity CRICOS Píovideí Code Numbeí 00115M © Copyíight La ľíobe Univeísity 2018 CSE5DMI WEEK 11 latrobe.edu.au Announcement Assignment-1 Marks Review Assignment-2 Consultation Sessions – Week 12 Lab Sessions Post Class Quizzes are finished Density Based Clustering Clusters are regions of high density that are separated from one another by regions on low density. DBSCAN Density-Based Spatial Clustering of Applications with Noise DBSCAN is a density-based algorithm. Density = number of points within a specified radius (Eps) A point is a core point if it has at least a specified number of points (MinPts) within Eps These are points that are at the interior of a cluster Counts the point itself A border point is not a core point, but is in the neighborhood of a core point A noise point is any point that is neither a core point nor a border point DBSCAN: Core, Border, and Noise Points MinPts = 7 DBSCAN: Core, Border, and Noise Points Original Points Point types: core, border and noise Eps = 10, MinPts = 4 DBSCAN Algorithm Form clusters using core points, and assign border points to one of its neighboring clusters 1: Label all points as core, border, or noise points. 2: Eliminate noise points. 3: Put an edge between all core points within a distance Eps of each other. 4: Make each group of connected core points into a separate cluster. 5: Assign each border point to one of the clusters of its associated core points DBSCAN: Determining EPS and MinPts Idea is that for points in a cluster, their kth nearest neighbors are at close distance Noise points have the kth nearest neighbor at farther distance So, plot sorted distance of every point to its kth nearest neighbor When DBSCAN Works Well Original Points Clusters (dark blue points indicate noise) Can handle clusters of different shapes and sizes Resistant to noise When DBSCAN Does NOT Work Well Original Points When DBSCAN Does NOT Work Well (MinPts=4, Eps=9.92). Original Points Varying densities High-dimensional data (MinPts=4, Eps=9.75) Cluster Validity For supervised classification we have a variety of measures to evaluate how good our model is Accuracy, precision, recall For cluster analysis, the analogous question is how to evaluate the “goodness” of the resulting clusters? But “clusters are in the eye of the beholder”! In practice the clusters we find are defined by the clustering algorithm Then why do we want to evaluate them? To avoid finding patterns in noise To compare clustering algorithms To compare two sets of clusters To compare two clusters Clusters found in Random Data 1 1 0.9 0.9 0.8 0.8 Random Points 0.7 0.6 0.5 0.7 0.6 0.5 DBSCAN 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0 0 0.2 0.4 0.6 0.8 1 x 0 0 0.2 0.4 0.6 0.8 1 x 1 1 K-means 0.9 0.8 0.7 0.6 0.9 0.8 0.7 0.6 Complete Link 0.5 0.5 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0 0 0.2 0.4 0.6 0.8 1 x 0 0 0.2 0.4 0.6 0.8 1 x Measures of Cluster Validity Numerical measures that are applied to judge various aspects of cluster validity, are classified into the following two types. Supervised: Used to measure the extent to which cluster labels match externally supplied class labels. Entropy Often called external indices because they use information external to the data Unsupervised: Used to measure the goodness of a clustering structure without respect to external information. Sum of Squared Error (SSE) Often called internal indices because they only use information in the data You can use supervised or unsupervised measures to compare clusters or clusterings Unsupervised Measures: Cohesion and Separation Example: SSE SSB + SSE = constant m 1 m1 2 3 4 m2 5 K=1 cluster: 𝑆𝑆𝐸 = 2 + 2 + 2 + 2 = 10 𝑆𝑆𝐵 = 4× 3 − 3 2 = 0 𝑇𝑜𝑡𝑎𝑙 = 10 + 0 = 10 K=2 clusters: 𝑆𝑆𝐸 = 2 + 2 + 2 + 2 = 1 𝑆𝑆𝐵 = 4.5 − 1.5 2 = 9 → 𝑀𝑒𝑡ℎ𝑜𝑑 1 𝑆𝑆𝐵 = 2 × 2 + 2× 2 = 9  Method 2 𝑇𝑜𝑡𝑎𝑙 = 1 + 9 = 10 Final Comment on Cluster Validity “The validation of clustering structures is the most difficult and frustrating part of cluster analysis. Without a strong effort in this direction, cluster analysis will remain a black art accessible only to those true believers who have experience and great courage.” Algorithms for Clustering Data, Jain and Dubes H. Xiong and Z. Li. Clustering Validation Measures. In C. C. Aggarwal and C. K. Reddy, editors, Data Clustering: Algorithms and Applications, pages 571–605. Chapman & Hall/CRC, 2013. Summary DBSCAN Main parameters Core point, border point, noise point How does a DBSCAN algorithm form clusters Thank you latíobe.edu.au La ľíobe Univeísity CRICOS Píovideí Code Numbeí 00115M © Copyíight La ľíobe Univeísity 2018

Use Quizgecko on...
Browser
Browser