Clustering and Object Similarity Evaluation Jiawei Han and
Clustering and Object Similarity Evaluation ©Jiawei Han and Micheline Kamber with Additions and Modifications by Ch. Eick Organization for COSC 6340: 1. What is Clustering? 2. Object Similarity Measurement 3. K-Means Clustering Algorithm 4. Hierarchical Clustering Han, Kamber, Eick: Object Similarity & Clustering 1
Examples of Clustering Applications n n n Marketing: Help marketers discover distinct groups in their customer bases, and then use this knowledge to develop targeted marketing programs Land use: Identification of areas of similar land use in an earth observation database Insurance: Identifying groups of motor insurance policy holders with a high average claim cost City-planning: Identifying groups of houses according to their house type, value, and geographical location Earth-quake studies: Observed earth quake epicenters should be clustered along continent faults Han, Kamber, Eick: Object Similarity & Clustering 3
Requirements of Clustering in Data Mining n Scalability n Ability to deal with different types of attributes n Discovery of clusters with arbitrary shape n Minimal requirements for domain knowledge to determine input parameters n Able to deal with noise and outliers n Insensitive to order of input records n High dimensionality n Incorporation of user-specified constraints n Interpretability and usability Han, Kamber, Eick: Object Similarity & Clustering 4
Data Structures for Clustering n n Data matrix n (n objects, p attributes) (Dis)Similarity matrix n (nxn) Han, Kamber, Eick: Object Similarity & Clustering 5
Quality Evaluation of Clusters n n n Dissimilarity/Similarity metric: Similarity is expressed in terms of a normalized distance function d, which is typically metric; typically: d (oi, oj) = 1 - d (oi, oj) There is a separate “quality” function that measures the “goodness” of a cluster. The definitions of similarity functions are usually very different for interval-scaled, boolean, categorical, ordinal and ratio variables. Weights should be associated with different variables based on applications and data semantics. It is hard to define “similar enough” or “good enough” n the answer is typically highly subjective. Han, Kamber, Eick: Object Similarity & Clustering 6
Challenges in Obtaining Object Similarity Measures n Many Types of Variables n n n Interval-scaled variables Binary variables and nominal variables Ordinal variables Ratio-scaled variables Objects are characterized by variables belonging to different types (mixture of variables) Han, Kamber, Eick: Object Similarity & Clustering 7
Case Study: Patient Similarity The following relation is given (with 10000 tuples): Patient(ssn, weight, height, cancer-sev, eye-color, age) n Attribute Domains n n ssn: 9 digits n weight between 30 and 650; mweight=158 sweight=24. 20 n height between 0. 30 and 2. 20 in meters; mheight=1. 52 sheight=19. 2 n cancer-sev: 4=serious 3=quite_serious 2=medium 1=minor n eye-color: {brown, blue, green, grey } n age: between 3 and 100; mage=45 sage=13. 2 Task: Define Patient Similarity Han, Kamber, Eick: Object Similarity & Clustering 8
Generating a Global Similarity Measure from Single Variable Similarity Measures Assumption: A database may contain up to six types of variables: symmetric binary, asymmetric binary, nominal, ordinal, interval and ratio. 1. Standardize variable and associate similarity measure di with the standardized i-th variable and determine weight wi of the i-th variable. 2. Create the following global (dis)similarity measure d: Han, Kamber, Eick: Object Similarity & Clustering 9
A Methodology to Obtain a Similarity Matrix 1. Understand Variables 2. Remove (non-relevant and redundant) Variables 3. (Standardize and) Normalize Variables (typically using zscores or variable values are transformed to numbers in [0, 1]) 4. Associate (Dis)Similarity Measure df/df with each Variable 5. Associate a Weight (measuring its importance) with each Variable 6. Compute the (Dis)Similarity Matrix 7. Apply Similarity-based Data Mining Technique (e. g. Clustering, Nearest Neighbor, Multi-dimensional Scaling, …) Han, Kamber, Eick: Object Similarity & Clustering 10
Interval-scaled Variables n Standardize data using z-scores n Calculate the mean absolute deviation: where n n Calculate the standardized measurement (z-score) Using mean absolute deviation is more robust than using standard deviation Han, Kamber, Eick: Object Similarity & Clustering 11
Normalization in [0, 1] Problem: If non-normalized variables are used the maximum distance between two values can be greater than 1. Solution: Normalize interval-scaled variables using where minf denotes the minimum value and maxf denotes the maximum value of the f-th attribute in the data set and s is constant that is choses depending on the similarity measure (e. g. if Manhattan distance is used s is chosen to be 1). Han, Kamber, Eick: Object Similarity & Clustering 12
Other Normalizations Goal: Limit the maximum distance to 1 n Start using a distance measure df(x, y) n Determine the maximum distance dmaxf that can occur for two values of the f-th attribute (e. g. dmaxf=maxf-minf ). n Define df(x, y)=1 - (df(x, y)/ dmaxf) Advantage: Negative similarities cannot occur. Han, Kamber, Eick: Object Similarity & Clustering 13
Similarity Between Objects n n Distances are normally used to measure the similarity or dissimilarity between two data objects Some popular ones include: Minkowski distance: where i = (xi 1, xi 2, …, xip) and j = (xj 1, xj 2, …, xjp) are two p-dimensional data objects, and q is a positive integer n If q = 1, d is Manhattan distance Han, Kamber, Eick: Object Similarity & Clustering 14
Similarity Between Objects (Cont. ) n If q = 2, d is Euclidean distance: n Properties n n n d(i, j) 0 d(i, i) = 0 d(i, j) = d(j, i) d(i, j) d(i, k) + d(k, j) Also one can use weighted distance, parametric Pearson product moment correlation, or other disimilarity measures. Han, Kamber, Eick: Object Similarity & Clustering 15
Similarity with respect to a Set of Binary Variables n A contingency table for binary data Object j Object i Ignores agreements in O’s Considers agreements in 0’s and 1’s to be equivalent. Han, Kamber, Eick: Object Similarity & Clustering 16
Similarity between Binary Variable Sets n Example n n n gender is a symmetric attribute the remaining attributes are asymmetric binary let the values Y and P be set to 1, and the value N be set to 0 Han, Kamber, Eick: Object Similarity & Clustering 17
Nominal Variables n n A generalization of the binary variable in that it can take more than 2 states, e. g. , red, yellow, blue, green Method 1: Simple matching n n m: # of matches, p: total # of variables Method 2: use a large number of binary variables n creating a new binary variable for each of the M nominal states Han, Kamber, Eick: Object Similarity & Clustering 18
Ordinal Variables n An ordinal variable can be discrete or continuous n order is important (e. g. UH-grade, hotel-rating) n Can be treated like interval-scaled n n n replacing xif by their rank: map the range of each variable onto [0, 1] by replacing the f-th variable of i-th object by compute the dissimilarity using methods for intervalscaled variables Han, Kamber, Eick: Object Similarity & Clustering 19
Ratio-Scaled Variables n n Ratio-scaled variable: a positive measurement on a nonlinear scale, approximately at exponential scale, such as Ae. Bt or Ae-Bt Methods: n treat them like interval-scaled variables — not a good choice! (why? ) n apply logarithmic transformation yif = log(xif) n treat them as continuous ordinal data treat their rank as interval-scaled. Han, Kamber, Eick: Object Similarity & Clustering 20
Case Study --- Normalization Patient(ssn, weight, height, cancer-sev, eye-color, age) n Attribute Relevance: ssn no; eye-color minor; other major n Attribute Normalization: n n n ssn remove! weight between 30 and 650; mweight=158 sweight=24. 20; transform to zweight= (xweight-158)/24. 20 (alternatively, zweight=(xweight-30)/620)); height normalize like weight! cancer_sev: 4=serious 3=quite_serious 2=medium 1=minor; transform 4 to 1, 3 to 2/3, 2 to 1/3, 1 to 0 and then normalize like weight! age: normalize like weight! Han, Kamber, Eick: Object Similarity & Clustering 21
Case Study --- Weight Selection and Similarity Measure Selection Patient(ssn, weight, height, cancer-sev, eye-color, age) n For normalized weight, height, cancer_sev, age values use Manhattan distance function; e. g. : dweight(w 1, w 2)= 1 - | ((w 1 -158)/24. 20 ) - ((w 2 -158)/24. 20) | n For eye-color use: deye-color(c 1, c 2)= if c 1=c 2 then 1 else 0 n Weight Assignment: 0. 2 for eye-color; 1 for all others Final Solution --- chosen Similarity Measure d: Let o 1=(s 1, w 1, h 1, cs 1, e 1, a 1) and o 2=(s 2, w 2, h 2, cs 2, e 2, a 2) d(o 1, o 2): = (dweight(w 1, w 2) + dheight(h 1, h 2) + dcancersev(cs 1, cs 2) + dage(a 1, a 2) + 0. 2* deye-color(e 1, e 2) ) /4. 2 Han, Kamber, Eick: Object Similarity & Clustering 22
Major Clustering Approaches n Partitioning algorithms: Construct various partitions and then evaluate them by some criterion n Hierarchy algorithms: Create a hierarchical decomposition of the set of data (or objects) using some criterion n Density-based: based on connectivity and density functions n Grid-based: based on a multiple-level granularity structure n Model-based: A model is hypothesized for each of the clusters and the idea is to find the best fit of that model to each other Han, Kamber, Eick: Object Similarity & Clustering 23
Partitioning Algorithms: Basic Concept n n Partitioning method: Construct a partition of a database D of n objects into a set of k clusters Given a k, find a partition of k clusters that optimizes the chosen partitioning criterion n Global optimal: exhaustively enumerate all partitions n Heuristic methods: k-means and k-medoids algorithms n k-means (Mac. Queen’ 67): Each cluster is represented by the center of the cluster n k-medoids or PAM (Partition around medoids) (Kaufman & Rousseeuw’ 87): Each cluster is represented by one of the objects in the cluster Han, Kamber, Eick: Object Similarity & Clustering 24
The K-Means Clustering Method n Given k, the k-means algorithm is implemented in 4 steps: n Partition objects into k nonempty subsets n Compute seed points as the centroids of the clusters of the current partition. The centroid is the center (mean point) of the cluster. n Assign each object to the cluster with the nearest seed point. n Go back to Step 2, stop when no more new assignment. Han, Kamber, Eick: Object Similarity & Clustering 25
The K-Means Clustering Method n Example Han, Kamber, Eick: Object Similarity & Clustering 26
Comments on the K-Means Method n Strength n n n Relatively efficient: O(tkn), where n is # objects, k is # clusters, and t is # iterations. Normally, k, t << n. Often terminates at a local optimum. The global optimum may be found using techniques such as: deterministic annealing and genetic algorithms Weakness n Applicable only when mean is defined, then what about categorical data? n Need to specify k, the number of clusters, in advance n Unable to handle noisy data and outliers n Not suitable to discover clusters with non-convex shapes Han, Kamber, Eick: Object Similarity & Clustering 27
Hierarchical Clustering n Use distance matrix as clustering criteria. This method does not require the number of clusters k as an input, but needs a termination condition Step 0 a b Step 1 Step 2 Step 3 Step 4 ab abcde c cde d de e Step 4 agglomerative (AGNES) Step 3 Han, Kamber, Eick: Object Similarity & Clustering Step 2 Step 1 Step 0 divisive (DIANA) 28
A Dendrogram Shows How the Clusters are Merged Hierarchically Decompose data objects into a several levels of nested partitioning (tree of clusters), called a dendrogram. A clustering of the data objects is obtained by cutting the dendrogram at the desired level, then each connected component forms a cluster. Han, Kamber, Eick: Object Similarity & Clustering 29
CAL-FU/UH Database Clustering Similarity Assessment Environments Library of clustering algorithms Object View Data Extraction Tool DBMS Han, Kamber, Eick: Object Similarity & Clustering Tool User Interface Training Date A set of clusters Similarity measure Similarity Measure Tool Default choices and domain information Learning Tool Library of similarity measures Type and weight information 30
Prototypes of Similarity Assessment Tools n n n Prototype 1 (CAL State Fullerton): Supported the interactive definition of similarity measures; knowledge representation format does not rely on modular units; provides a nearest neighbor clustering algorithm for database clustering; functions were supported outside a DBMS Prototype 2 (UH): Similarity measures are defined using a special language (not interactively); tool supports modular units and functions are provided using a Java/SQL-Server 2000 framework; functions were partially moved inside a DBMS (although some are still inside Java); analysis results are stored in the database and therefore available for further analysis. Prototype 3 (UH): Supports the learning of similarity measures, functions are provided inside the DBMS, other capabilities? ? ? Han, Kamber, Eick: Object Similarity & Clustering 31
Self-organizing feature maps (SOMs) n n n SOM employ neural network techniques for clustering Clustering is also performed by having several units competing for the current object The unit whose weight vector is closest to the current object wins The winner and its neighbors learn by having their weights adjusted SOMs are believed to resemble processing that can occur in the brain Useful for visualizing high-dimensional data in 2 - or 3 -D space Han, Kamber, Eick: Object Similarity & Clustering 32
Problems and Challenges n n n Considerable progress has been made in scalable clustering methods n Partitioning: k-means, k-medoids, CLARANS n Hierarchical: BIRCH, CURE n Density-based: DBSCAN, CLIQUE, OPTICS n Grid-based: STING, Wave. Cluster n Model-based: Autoclass, Denclue, Cobweb Current clustering techniques do not address all the requirements adequately Constraint-based clustering analysis: Constraints exist in data space (bridges and highways) or in user queries Han, Kamber, Eick: Object Similarity & Clustering 33
Summary Object Similarity & Clustering n n Cluster analysis groups objects based on their similarity and has wide applications Appropriate similarity measures have to be chosen for various types of variables and combined into a global similarity measure. Clustering algorithms can be categorized into partitioning methods, hierarchical methods, density-based methods, grid-based methods, and model-based methods Methods to measure, compute, and learn object similarity are quite important, not only for clustering, but also for nearest neighbor approaches, information retrieval in general, and for data visualization. Han, Kamber, Eick: Object Similarity & Clustering 34
References (1) n n n n n R. Agrawal, J. Gehrke, D. Gunopulos, and P. Raghavan. Automatic subspace clustering of high dimensional data for data mining applications. SIGMOD'98 M. R. Anderberg. Cluster Analysis for Applications. Academic Press, 1973. M. Ankerst, M. Breunig, H. -P. Kriegel, and J. Sander. Optics: Ordering points to identify the clustering structure, SIGMOD’ 99. P. Arabie, L. J. Hubert, and G. De Soete. Clustering and Classification. World Scietific, 1996 M. Ester, H. -P. Kriegel, J. Sander, and X. Xu. A density-based algorithm for discovering clusters in large spatial databases. KDD'96. M. Ester, H. -P. Kriegel, and X. Xu. Knowledge discovery in large spatial databases: Focusing techniques for efficient class identification. SSD'95. D. Fisher. Knowledge acquisition via incremental conceptual clustering. Machine Learning, 2: 139 -172, 1987. D. Gibson, J. Kleinberg, and P. Raghavan. Clustering categorical data: An approach based on dynamic systems. In Proc. VLDB’ 98. S. Guha, R. Rastogi, and K. Shim. Cure: An efficient clustering algorithm for large databases. SIGMOD'98. A. K. Jain and R. C. Dubes. Algorithms for Clustering Data. Printice Hall, 1988. Han, Kamber, Eick: Object Similarity & Clustering 35
References (2) n n n n n L. Kaufman and P. J. Rousseeuw. Finding Groups in Data: an Introduction to Cluster Analysis. John Wiley & Sons, 1990. E. Knorr and R. Ng. Algorithms for mining distance-based outliers in large datasets. VLDB’ 98. G. J. Mc. Lachlan and K. E. Bkasford. Mixture Models: Inference and Applications to Clustering. John Wiley and Sons, 1988. P. Michaud. Clustering techniques. Future Generation Computer systems, 13, 1997. R. Ng and J. Han. Efficient and effective clustering method for spatial data mining. VLDB'94. E. Schikuta. Grid clustering: An efficient hierarchical clustering method for very large data sets. Proc. 1996 Int. Conf. on Pattern Recognition, 101 -105. G. Sheikholeslami, S. Chatterjee, and A. Zhang. Wave. Cluster: A multi-resolution clustering approach for very large spatial databases. VLDB’ 98. W. Wang, Yang, R. Muntz, STING: A Statistical Information grid Approach to Spatial Data Mining, VLDB’ 97. T. Zhang, R. Ramakrishnan, and M. Livny. BIRCH : an efficient data clustering method for very large databases. SIGMOD'96. Han, Kamber, Eick: Object Similarity & Clustering 36
- Slides: 35