Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science...

43
Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University of Central Arkansas Fall 2010

description

What is Cluster Analysis? Clustering analysis is an important human activity Early in childhood, we learn how to distinguish between cats and dogs Unsupervised learning: no predefined classes Typical applications As a stand-alone tool to get insight into data distribution As a preprocessing step for other algorithms

Transcript of Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science...

Page 1: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Cluster Analysis

Dr. Bernard Chen Ph.D.Assistant Professor

Department of Computer Science University of Central Arkansas

Fall 2010

Page 2: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

What is Cluster Analysis? Cluster: a collection of data objects

Similar to one another within the same cluster

Dissimilar to the objects in other clusters

Cluster analysis Finding similarities between data according to

the characteristics found in the data and grouping similar data objects into clusters

Page 3: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

What is Cluster Analysis? Clustering analysis is an important human

activity Early in childhood, we learn how to distinguish

between cats and dogs

Unsupervised learning: no predefined classes

Typical applications As a stand-alone tool to get insight into data distribution As a preprocessing step for other algorithms

Page 4: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Clustering: Rich Applications and Multidisciplinary Efforts

Pattern Recognition Spatial Data Analysis

Create thematic maps in GIS by clustering feature spaces Detect spatial clusters or for other spatial mining tasks

Image Processing Economic Science (especially market research) WWW

Document classification Cluster Weblog data to discover groups of similar access

patterns

Page 5: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Quality: What Is Good Clustering? A good clustering method will produce high quality

clusters with high intra-class similarity

(Similar to one another within the same cluster) low inter-class similarity

(Dissimilar to the objects in other clusters)

The quality of a clustering method is also measured by its ability to discover some or all of the hidden patterns

Page 6: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Similarity and Dissimilarity Between Objects

Distances are normally used to measure the similarity or dissimilarity between two data objects

Some popular ones include: Minkowski distance:

where i = (xi1, xi2, …, xip) and j = (xj1, xj2, …, xjp) are two p-dimensional data objects, and q is a positive integer

If q = 1, d is Manhattan distance

q q

pp

qq

jxixjxixjxixjid )||...|||(|),(2211

||...||||),(2211 pp jxixjxixjxixjid

Page 7: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Similarity and Dissimilarity Between Objects (Cont.)

If q = 2, d is Euclidean distance:

Also, one can use weighted distance, parametric Pearson correlation, or other disimilarity measures

)||...|||(|),( 22

22

2

11 pp jxixjxixjxixjid

Page 8: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Major Clustering Approaches Partitioning approach:

Construct various partitions and then evaluate them by some criterion, e.g., minimizing the sum of square errors

Typical methods: k-means, k-medoids, CLARANS Hierarchical approach:

Create a hierarchical decomposition of the set of data (or objects) using some criterion

Typical methods: Hierarchical, Diana, Agnes, BIRCH, ROCK, CAMELEON Density-based approach:

Based on connectivity and density functions Typical methods: DBSACN, OPTICS, DenClue

Page 9: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Some Other Major Clustering Approaches Grid-based approach:

based on a multiple-level granularity structure Typical methods: STING, WaveCluster, CLIQUE

Model-based: A model is hypothesized for each of the clusters and tries to find the best fit of that

model to each other Typical methods: EM, SOM, COBWEB

Frequent pattern-based: Based on the analysis of frequent patterns Typical methods: pCluster

User-guided or constraint-based: Clustering by considering user-specified or application-specific constraints Typical methods: COD (obstacles), constrained clustering

Page 10: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Typical Alternatives to Calculate the Distance between Clusters Single link: smallest distance between an element in one

cluster and an element in the other, i.e., dis(Ki, Kj) = min(tip, tjq)

Complete link: largest distance between an element in one cluster and an element in the other, i.e., dis(Ki, Kj) = max(tip, tjq)

Average: avg distance between an element in one cluster and an element in the other, i.e., dis(Ki, Kj) = avg(tip, tjq)

Page 11: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Typical Alternatives to Calculate the Distance between Clusters Centroid: distance between the centroids of two

clusters, i.e., dis(Ki, Kj) = dis(Ci, Cj) Centroid: the “middle” of a cluster

Medoid: distance between the medoids of two clusters, i.e., dis(Ki, Kj) = dis(Mi, Mj)

Medoid: one chosen, centrally located object in the cluster

N

tNi ip

mC)(1

Page 12: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Clustering Approaches1. Partitioning Methods2. Hierarchical Methods3. Density-Based Methods

Page 13: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Partitioning Algorithms: Basic Concept Partitioning method: Construct a

partition of a database D of n objects into a set of k clusters, s.t., min sum of squared distance 2

1 )( mimKmtkm tC

mi

Page 14: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Partitioning Algorithms: Basic Concept Given a k, find a partition of k clusters that optimizes

the chosen partitioning criterion

Global optimal: exhaustively enumerate all partitions

Heuristic methods: k-means and k-medoids algorithms k-means (MacQueen’67): Each cluster is represented by the

center of the cluster k-medoids or PAM (Partition around medoids) (Kaufman &

Rousseeuw’87): Each cluster is represented by one of the objects in the cluster

Page 15: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

The K-Means Clustering Method

Given k, the k-means algorithm is implemented in four steps:

1. Partition objects into k nonempty subsets2. Compute seed points as the centroids of the clusters

of the current partition (the centroid is the center, i.e., mean point, of the cluster)

3. Assign each object to the cluster with the nearest seed point

4. Go back to Step 2, stop when no more new assignment

Page 16: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

K-means Clustering

Page 17: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

K-means Clustering

Page 18: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

K-means Clustering

Page 19: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

K-means Clustering

Page 20: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

K-means Clustering

Page 21: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

The K-Means Clustering Method

0

1

2

3

4

5

6

7

8

9

10

0 1 2 3 4 5 6 7 8 9 100

1

2

3

4

5

6

7

8

9

10

0 1 2 3 4 5 6 7 8 9 10

0

1

2

3

4

5

6

7

8

9

10

0 1 2 3 4 5 6 7 8 9 100

1

2

3

4

5

6

7

8

9

10

0 1 2 3 4 5 6 7 8 9 10

0

1

2

3

4

5

6

7

8

9

10

0 1 2 3 4 5 6 7 8 9 10

K=2Arbitrarily choose K object as initial cluster center

Assign each objects to most similar center

Update the cluster means

Update the cluster means

reassignreassign

Page 22: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Example Run K-means clustering with 3

clusters (initial centroids: 3, 16, 25) for at least 2 iterations

Page 23: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Example Centroids:3 – 2 3 4 7 9 new centroid: 5

16 – 10 11 12 16 18 19 new centroid: 14.33

25 – 23 24 25 30 new centroid: 25.5

Page 24: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Example Centroids:5 – 2 3 4 7 9 new centroid: 5

14.33 – 10 11 12 16 18 19 new centroid: 14.33

25.5 – 23 24 25 30 new centroid: 25.5

Page 25: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

In class Practice Run K-means clustering with 3

clusters (initial centroids: 3, 12, 19) for at least 2 iterations

Page 26: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Typical Alternatives to Calculate the Distance between Clusters Single link: smallest distance between an element in one

cluster and an element in the other, i.e., dis(Ki, Kj) = min(tip, tjq)

Complete link: largest distance between an element in one cluster and an element in the other, i.e., dis(Ki, Kj) = max(tip, tjq)

Average: avg distance between an element in one cluster and an element in the other, i.e., dis(Ki, Kj) = avg(tip, tjq)

Page 27: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Typical Alternatives to Calculate the Distance between Clusters Centroid: distance between the centroids of two

clusters, i.e., dis(Ki, Kj) = dis(Ci, Cj) Centroid: the “middle” of a cluster

Medoid: distance between the medoids of two clusters, i.e., dis(Ki, Kj) = dis(Mi, Mj)

Medoid: one chosen, centrally located object in the cluster

N

tNi ip

mC)(1

Page 28: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Comments on the K-Means Method Strength: Relatively efficient: O(tkn), where n is #

objects, k is # clusters, and t is # iterations. Normally, k, t << n.

Weakness Applicable only when mean is defined, then what about

categorical data? Need to specify k, the number of clusters, in advance Unable to handle noisy data and outliers Not suitable to discover clusters with non-convex shapes

Page 29: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

What Is the Problem of the K-Means Method?

The k-means algorithm is sensitive to outliers !

Since an object with an extremely large value may substantially distort the distribution of the data.

K-Medoids: Instead of taking the mean value of the object in a cluster as a reference point, medoids can be used, which is the most centrally located object in a cluster.

0

1

2

3

4

5

6

7

8

9

10

0 1 2 3 4 5 6 7 8 9 100

1

2

3

4

5

6

7

8

9

10

0 1 2 3 4 5 6 7 8 9 10

Page 30: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering Fuzzy c-means (FCM) is a method of

clustering which allows one piece of data to belong to two or more clusters.

This method (developed by Dunn in 1973 and improved by Bezdek in 1981) is frequently used in pattern recognition.

Page 31: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering

Page 32: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering

Page 33: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering

Page 34: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering

Page 35: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering

Page 36: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering

Page 37: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering

Page 38: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clusteringhttp://home.dei.polimi.it/matteucc/Clustering/tutorial_html/cmeans.html

                                                                             

Page 39: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering For example: we have initial centroid 3 & 11

(with m=2)

For node 2 (1st element): U11 = The membership of first node to first cluster

U12 =The membership of first node to second cluster

%78.988281

8111

1

11232

3232

1

122

122

%22.1821

1811

112112

32112

1

122

122

Page 40: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering For example: we have initial centroid 3 & 11

(with m=2)

For node 3 (2nd element): U21 = 100% The membership of second node to first cluster

U22 = 0%The membership of second node to second cluster

Page 41: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering For example: we have initial centroid 3 & 11

(with m=2)

For node 4 (3rd element): U31 = The membership of first node to first cluster

U32 =The membership of first node to second cluster

%98

49501

4911

1

11434

3434

1

122

122

%2501

1491

114114

34114

1

122

122

Page 42: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering For example: we have initial centroid 3 & 11

(with m=2)

For node 7 (4th element): U41 = The membership of fourth node to first cluster

U42 =The membership of fourth node to second cluster

%5021

111

11737

3737

1

122

122

%5021

111

117117

37117

1

122

122

Page 43: Cluster Analysis Dr. Bernard Chen Ph.D. Assistant Professor Department of Computer Science University…

Fuzzy C-means Clustering C1= ...%)50(%)98(%)100(%)78.98(

...7*%)50(4*%)98(3*%)100(2*%)78.98(2222

2222