Professional Documents
Culture Documents
Chapters 8 & 9
Cluster Analysis
What Is Cluster Analysis
2
What is Cluster Analysis?
Inter-cluster
Intra-cluster distances are
distances are maximized
minimized
3
Applications of Cluster Analysis
Discovered Clusters Industry Group
Understanding Applied-Matl-DOWN,Bay-Network-Down,3-COM-DOWN,
characteristics, play an
2 ADV-Micro-Device-DOWN,Andrew-Corp-DOWN,
Computer-Assoc-DOWN,Circuit-City-DOWN,
Compaq-DOWN, EMC-Corp-DOWN, Gen-Inst-DOWN,
Technology2-DOWN
Motorola-DOWN,Microsoft-DOWN,Scientific-Atl-DOWN
important role in how people Fannie-Mae-DOWN,Fed-Home-Loan-DOWN,
analyze and describe the 3 MBNA-Corp-DOWN,Morgan-Stanley-DOWN Financial-DOWN
world. Baker-Hughes-UP,Dresser-Inds-UP,Halliburton-HLD-UP,
4 Louisiana-Land-UP,Phillips-Petro-UP,Unocal-UP,
Schlumberger-UP
Oil-UP
4
What is not Cluster Analysis?
Supervised classification
– Have class label information
Simple segmentation
– Dividing students into different registration groups
alphabetically, by last name
Results of a query
– Groupings are a result of an external specification
Graph partitioning
– If the purpose is to divide a graph into some sub-graphs
5
Notion of a Cluster can be Ambiguous
6
Types of Clusterings (1/2)
7
Partitional Clustering
8
Hierarchical Clustering
p1
p3 p4
p2
p1 p2 p3 p4
Traditional Hierarchical Clustering Traditional Dendrogram
p1
p3 p4
p2
p1 p2 p3 p4
Non-traditional Hierarchical Clustering Non-traditional Dendrogram
9
A hierarchical clustering can be viewed as a
sequence of partitional clusterings and a
partitional clustering can be obtained by taking
any member of that sequence; i.e., by cutting the
hierarchical tree at a particular level.
10
Types of Clusterings (2/2)
Well-separated clusters
Density-based clusters
Shared-Property or Conceptual
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.
– Sometimes a threshold is used to specify that all the objects in
a cluster must be sufficiently close to one another.
3 well-separated clusters
13
Types of Clusters: Center-Based (Prototype)
Center-based
– A cluster is a set of objects such that an object in a cluster is
closer (more similar) to the “center” of a cluster, than to the
center of any other cluster Continuous data
4 center-based clusters
14
Types of Clusters: Contiguity-Based (Graph)
8 contiguous clusters
15
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
16
Types of Clusters: Conceptual Clusters
(Shared Property)
2 Overlapping Circles
17
Types of Clusters: Objective Function
21
SOM Neural Network
22
Network Structure
5X5 topology
Output Layer
Node (j, k)
23
Network Structure
24
Basic Concept (1/8)
25
Basic Concept (2/8)
a
Topology coordinate
b a : (1,3)
Xt b : (3,1)
26
Basic Concept (3/8)
(n+2)th iteration
27
Basic Concept (4/8)
28
Basic Concept (5/8)
rj (X j Cx ) 2 (Yj Cy ) 2
where
X j , Y j = The coordinate values for jth output node.
C x , C y = The coordinate values of the neighborhood center.
30
Basic Concept (7/8)
R
R
Rn=R_rate x Rn-1
32
Algorithm-Training (1/5)
33
Algorithm Training (2/5)
Input Layer
34
Algorithm-Training (3/5)
Y[ j ][ k ] = 0
Input Layer
35
Algorithm-Training (4/5)
where
R = Neighborhood radius
neighborhood[ j ][ k ]=exp(-r[ j ][ k ] / R)
r[ j ][ k ]=[(X_Node[ j ][ k ] - X_Node[ j* ][ k* ])2
+(Y_Node[ j ][ k ] - Y_Node[ j* ][ k* ])2]1/2
36
Algorithm-Training (5/5)
38
An Example of Output Topology
Frequency
Output- Y axis
Output- X axis
39
Error Measure
where d jp,k i i , j ,k
(
i
X p
W ) 2
P: Training sample
The average of total
distances can be used as
the termination criterion. Output Layer
40
Input Layer
Homework 3 (1/2)
Appendix 1 250
200 385N
Error
150
誤 差
585N
100
785N
50
0
1 10 20 30 40 50 60 70 80 90 100
學 習 循 環
Training iteration
Appendix 2
Frequency Topology k
Topology j
42
K-Means
43
K-means Clustering
44
K-Means Example
Training samples
Training samples
10
x4
9
x2
8
7
6 x6
5
4
3
x7 x8
2
x1 1
x3 x5
0
-2 -1 0 1 2 3 4 5 6 7
46
K-Means Example
47
K-Means Example
48
K-Means Example
1 12 1 02 1
Distance between x1 1,1 and z2 2,8
1 2 1 8 7.616
2 2
49
K-Means Example
Z1 Z2 Z3
X1 1.000 7.616 7.071
X2 8.944 1.000 8.544
X3 1.000 8.246 6.000
X4 10.296 2.236 9.220
X5 6.000 8.544 1.000
X6 7.211 2.236 6.708
X7 2.828 6.083 5.385
X8 7.280 7.211 2.000
50
K-Means Example
Z1 X Y
1,1 0,0 1,2
new 1
cluster coordinate coordinate z1
3
X1 -1 1
0,1
X3 0 0
X7 1 2
52
K-Means Example
Z2 X Y
cluster coordinate coordinate
3,8 4,9 3,6
new 1
X2 3 8 z 2
3
3.333,7.667
X4 4 9
X6 3 6
5,0 6,2
Z3 X Y new 1
cluster coordinate coordinate z 3
2
5.5,1
X5 5 0
X8 6 2
53
K-Means Example
Z1new 0 1
Z3new 5.5 1
54
K-Means Example
55
K-Means Example
56
K-Means Example
Z1new 0 1
Z3new 5.5 1
57
K-Means Example
58
K-means Clustering – Details
60
Centroids and Objective Functions
61
Assigning Points to the Closest Centroid
62
Evaluating K-means Clusters
63
Two different K-means Clusterings
3
2.5
2
Original Points
1.5
y
1
0.5
3 3
2.5 2.5
2 2
1.5 1.5
y
y
1 1
0.5 0.5
0 0
Iteration 6
1
2
3
4
5
3
2.5
1.5
y
0.5
65
Importance of Choosing Initial Centroids
Iteration 1 Iteration 2 Iteration 3
3 3 3
2 2 2
y
1 1 1
0 0 0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2
x x x
2 2 2
y
1 1 1
0 0 0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2
x x x
66
Importance of Choosing Initial Centroids …
Iteration 5
1
2
3
4
3
2.5
1.5
y
0.5
67
Importance of Choosing Initial Centroids …
Iteration 1 Iteration 2
3 3
2.5 2.5
2 2
1.5 1.5
y
y
1 1
0.5 0.5
0 0
2 2 2
y
1 1 1
0 0 0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2
x x x
68
Problems with Selecting Initial Points
69
10 Clusters Example
Iteration 1 Iteration 2
8 8
6 6
4 4
2 2
y
y
0 0
-2 -2
-4 -4
-6 -6
0 5 10 15 20 0 5 10 15 20
x x
Iteration 3 Iteration 4
8 8
6 6
4 4
2 2
y
y
0 0
-2 -2
-4 -4
-6 -6
0 5 10 15 20 0 5 10 15 20
x x
Starting with two initial centroids in one cluster of each pair of clusters
70
10 Clusters Example
Iteration 4
1
2
3
8
2
y
-2
-4
-6
0 5 10 15 20
x
Starting with two initial centroids in one cluster of each pair of clusters
71
10 Clusters Example
Iteration 1 Iteration 2
8 8
6 6
4 4
2 2
y
y
0 0
-2 -2
-4 -4
-6 -6
0 5 10 15 20 0 5 10 15 20
x
Iteration 3 x
Iteration 4
8 8
6 6
4 4
2 2
y
y
0 0
-2 -2
-4 -4
-6 -6
0 5 10 15 20 0 5 10 15 20
x x
Starting with some pairs of clusters having three initial centroids, while other have only one.
72
10 Clusters Example
Iteration 4
1
2
3
8
2
y
-2
-4
-6
0 5 10 15 20
x
Starting with some pairs of clusters having three initial centroids, while other have only one.
73
Solutions to Initial Centroids Problem
Multiple runs
– Helps, but probability is not on your side
Take a sample of points and cluster them using a
hierarchical clustering tech to determine initial
centroids
Select more than k initial centroids and then
select among these initial centroids
– Select most widely separated
– Limitations
The sample is relatively small
K is relatively small compared to the sample size
74
Select the first point at random and then select
the next point which is farthest from any of the
initial centroids already selected. (well separated)
– But, outliers may be selected.
– Expensive to compute the farthest point from the
current set of initial centroids.
Post-processing (in page 78)
Bisecting K-means
– Not as susceptible to initialization issues
75
Handling Empty Clusters
76
Outliers
77
Reducing the SSE with Pre-processing
and Post-processing
Pre-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
78
Two strategies that decrease the total SSE
– Split a cluster: The cluster with the largest SSE is
usually chosen, but we could also split the cluster with
the largest standard deviation for one particular
attribute.
– Introduce a new cluster centroid: Often the point that
is farthest from any cluster is chosen. Random
selection is another approach.
Two strategies that decrease the number of
clusters
– Disperse a cluster: Remove the centroid that
corresponds to the cluster and reassigning the points
to other clusters.
– Merge two clusters: The clusters with the closest
79
centroids are typically chosen.
Updating Centers Incrementally
80
Bisecting K-means
81
Limitations of K-means
82
Limitations of K-means: Differing Sizes
83
Limitations of K-means: Differing Density
84
Limitations of K-means: Non-globular Shapes
85
Overcoming K-means Limitations
87
Overcoming K-means Limitations
88
Hierarchical Clustering
89
Hierarchical Clustering
6 5
0.2
4
3 4
0.15 2
5
2
0.1
1
0.05
3 1
0
1 3 2 5 4 6
90
Strengths of Hierarchical Clustering
91
Hierarchical Clustering
– Divisive:
Start with one, all-inclusive cluster
At each step, split a cluster until each cluster contains a point (or
there are k clusters)
93
Starting Situation
p2
p3
p4
p5
.
.
. Proximity Matrix
...
p1 p2 p3 p4 p9 p10 p11 p12
94
Intermediate Situation
C2
C3
C3
C4
C4
C5
Proximity Matrix
C1
C2 C5
...
p1 p2 p3 p4 p9 p10 p11 p12
95
Intermediate Situation
We want to merge the two closest clusters (C2 and C5) and
update the proximity matrix. C1 C2 C3 C4 C5
C1
C2
C3
C3
C4
C4
C5
Proximity Matrix
C1
C2 C5
...
p1 p2 p3 p4 p9 p10 p11 p12
96
After Merging
C1 ?
C2 U C5 ? ? ? ?
C3
C3 ?
C4
C4 ?
Proximity Matrix
C1
C2 U C5
...
p1 p2 p3 p4 p9 p10 p11 p12
97
How to Define Inter-Cluster Similarity
p1 p2 p3 p4 p5 ...
p1
Similarity?
p2
p3
p4
p5
MIN
.
MAX
.
Group Average .
Proximity Matrix
Distance Between Centroids
Other methods driven by an objective
function
– Ward’s Method uses squared error
98
How to Define Inter-Cluster Similarity
p1 p2 p3 p4 p5 ...
p1
p2
p3
p4
The proximity between the closest two
points that are in different clusters p5
MIN
.
MAX
.
Group Average .
Proximity Matrix
Distance Between Centroids
Other methods driven by an objective
function
– Ward’s Method uses squared error
99
How to Define Inter-Cluster Similarity
p1 p2 p3 p4 p5 ...
p1
p2
p3
p4
p5
Proximity between the farthest two
MIN points in different clusters
.
MAX
.
Group Average .
Proximity Matrix
Distance Between Centroids
Other methods driven by an objective
function
– Ward’s Method uses squared error
100
How to Define Inter-Cluster Similarity
p1 p2 p3 p4 p5 ...
p1
p2
p3
p4
The average pairwise
p5
MIN proximities of all pairs of
points from different
.
MAX clusters
.
Group Average .
Proximity Matrix
Distance Between Centroids
Other methods driven by an objective
function
– Ward’s Method uses squared error
101
How to Define Inter-Cluster Similarity
p1 p2 p3 p4 p5 ...
p1
p2
p3
p4
MIN p5
MAX .
.
Group Average
.
Distance Between Centroids Proximity Matrix
Other methods driven by an objective function
– Ward’s Method uses squared error
Like distance between centroids, but it measures
the proximity between two clusters in term of the
increase in the SSE that results from merging the
102
two clusters.
103
Cluster Similarity: MIN or Single Link
104
Hierarchical Clustering: MIN
105
Strength of MIN
106
Limitations of MIN
107
Cluster Similarity: MAX or Complete Linkage
108
Hierarchical Clustering: MAX
109
Strength of MAX
110
Limitations of MAX
111
Cluster Similarity: Group Average
proximity(p , p )
piClusteri
i j
p jClusterj
proximity(Clusteri , Clusterj )
|Clusteri ||Clusterj |
112
Hierarchical Clustering: Group Average
113
Hierarchical Clustering: Group Average
Strengths
– Less susceptible to noise and outliers
114
Cluster Similarity: Ward’s Method
115
116
Hierarchical Clustering: Time and Space requirements
117
Hierarchical Clustering: Problems and Limitations
118
Cluster Validity
119
Cluster Validity
120
Clusters found in Random Data
1 1
0.9 0.9
0.8 0.8
0.7 0.7
y
0.4 0.4
0.3 0.3
0.2 0.2
0.1 0.1
0 0
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
x x
1 1
0.9 0.9
0.8 0.8
K-means Complete
0.7 0.7
Link
0.6 0.6
0.5 0.5
y
0.4 0.4
0.3 0.3
0.2 0.2
0.1 0.1
0 0
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
x x
121
Different Aspects of Cluster Validation
122
Some Challenges for Numerical Measure
123
Measures of Cluster Validity
BSS Ci (m mi )2
i
– Where |Ci| is the size of cluster i
125
Internal Measures: Cohesion and Separation
Example: SSE
– BSS + WSS = constant
m
1 m1 2 3 4 m2 5
6 9
8
4
7
2 6
SSE
5
0
4
-2 3
2
-4
1
-6 0
2 5 10 15 20 25 30
5 10 15
K
127
Internal Measures: SSE
1
2 6
3
4
128
Unsupervised Cluster Evaluation Using
Cohesion and Separation
129
Graph-Based View of Cohesion and
Separation
The cohesion of a cluster can be defined as the
sum of the weights of the links in the proximity
graph that connect points within the cluster.
The separation between two clusters can be
measured by the sum of the weights of the links
from points in one cluster to points in the other
cluster.
130
cohesion separation
cohesion(Ci ) proximity( x, y)
xCi
yCi
separation(Ci , C j ) proximity( x, y)
xCi
yC j
131
Prototype-Based View of Cohesion and
Separation
The cohesion of a cluster can be defined as the sum of the
proximities with respect to the prototype (centroid or
medoid).
The separation between two clusters can be measured by
the proximity of the two cluster prototypes.
cohesion(Ci ) proximity( x, ci )
xCi
132
Both the cluster cohesion measure and
separation measure can be combined together
using the following equation:
k
overall _ validity wi validity(Ci )
i 1
Can calculate the Average Silhouette width for all the points in a
cluster.
134
Determining the Correct Number of
Clusters
It is necessary to use some measures to
determine the number of clusters
135
Wilk’s Lambdan value is the other choice for
determining the number of clusters.
SSwithin
Wilk ' s Lambda
SStotal
ART2 ART2
Wilk’s Wilk’s
parameters Number of parameter Number of
Lambda Difference Lambda Difference
vigilance clusters vigilance clusters
Value Value
value value
0.96 80 0.49511 0.0486 0.9491 59 0.5899 0.0160
137
Supervised Measures of Cluster Validity
Classification-orientated measure
Similarity-orientated measure
(See next page)
138
Classification-Oriented Measure of
Cluster Validity
Measure the degree to which predicted class
labels correspond to actual class labels.
– Entropy
– Purity
– Precision
– Recall
– F-measure (Combination of Precision and Recall)
139
External Measures of Cluster Validity: Entropy and Purity
140
Similarity-Oriented Measure of Cluster
Validity
Compare two matrices:
– The ideal cluster similarity matrix which has a 1 in the
ijth entry if two objects, i and j, are in the same cluster
and 0, otherwise.
– The ideal class similarity matrix which has a 1 in the
ijth entry if two objects, i and j, belong to the same
class, a 0 otherwise.
Point Point
p1 p2 p3 p4 p5 p1 p2 p3 p4 p5
P1 1 1 1 0 0 P1 1 1 0 0 0
Correlation
P2 1 1 1 0 0 P2 1 1 0 0 0
=0.359
P3 1 1 1 0 0 P3 0 0 1 1 1
P4 0 0 0 1 1 P4 0 0 1 1 1
p5 0 0 0 1 1 p5 0 0 1 1 1
Clustered results 141
Actual results
Final Comment on Cluster Validity
142
THE END!
143