Download Data Mining Cluster Analysis: Basic Concepts and Algorithms

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Principal component analysis wikipedia , lookup

Nonlinear dimensionality reduction wikipedia , lookup

Human genetic clustering wikipedia , lookup

K-means clustering wikipedia , lookup

Cluster analysis wikipedia , lookup

Nearest-neighbor chain algorithm wikipedia , lookup

Transcript
Data Mining
Cluster Analysis: Basic Concepts
and Algorithms
Lecture Notes for Chapter 8
Introduction to Data Mining
by
Tan, Steinbach, Kumar
© Tan,Steinbach, Kumar
Introduction to Data Mining
4/18/2004
1
Hierarchical Clustering
Produces a set of nested clusters organized as a
hierarchical tree
z Can be visualized as a dendrogram
z
– A tree like diagram that records the sequences of
merges or splits
5
6
0.2
4
3
4
2
0.15
5
2
0.1
1
0.05
3
0
1
3
2
5
4
6
1
Strengths of Hierarchical Clustering
z
Do not have to assume any particular number of
clusters
– Any desired number of clusters can be obtained by
‘cutting’ the dendogram at the proper level
z
They may correspond to meaningful taxonomies
– Example in biological sciences (e
(e.g.,
g animal kingdom
kingdom,
phylogeny reconstruction, …)
Hierarchical Clustering
z
Hierarchical clustering is most frequently performed in an
agglomerative manner
– Start with the points as individual clusters
– At each step, merge the closest pair of clusters until only one cluster
(or k cclusters)
(o
uste s) left
et
z
Traditional hierarchical algorithms use a similarity or
distance matrix
– Merge or split one cluster at a time
Agglomerative Clustering Algorithm
z
Most popular hierarchical clustering technique
z
Basic algorithm is straightforward
1.
Compute the proximity (distance) matrix
2.
Let each data point be a cluster
3.
Repeat
4.
Merge the two closest clusters
5
5.
Update the proximity matrix
6.
z
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
l t
di
distinguish
ti
i h th
the diff
differentt algorithms
l ith
Starting Situation
z
Start with clusters of individual points and a
proximity matrix
p1 p2
p3
p4 p5
p1
p2
p3
p4
p5
.
.
.
Proximity Matrix
...
Intermediate Situation
z
After some merging steps, we have some clusters
C1
C2
C3
C4
C1
C2
C3
C3
C4
C4
C5
Proximity Matrix
C1
C2
C5
C5
Intermediate Situation
z
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
After Merging
z
The question is “How do we update the proximity matrix?”
C1
C1
C2 U C5
C3
C4
C2
U
C5
C3
C4
?
?
?
?
?
C3
?
C4
?
Proximity Matrix
C1
C2 U C5
How to Define Inter-Cluster Similarity
p1
Similarity?
p2
p3
p4 p5
p1
p2
p3
p4
z
z
z
z
z
p5
MIN
.
MAX
.
Group Average
.
Proximity Matrix
Distance Between Centroids
Other methods driven by an objective
function
– Ward
Ward’s
s Method uses squared error
...
How to Define Inter-Cluster Similarity
p1
p2
p3
p4 p5
p1
p2
p3
p4
z
z
z
z
z
p5
MIN
.
MAX
.
Group Average
.
Proximity Matrix
Distance Between Centroids
Other methods driven by an objective
function
– Ward
Ward’s
s Method uses squared error
...
How to Define Inter-Cluster Similarity
p1
p2
p3
p4 p5
p1
p2
p3
p4
z
z
z
z
z
p5
MIN
.
MAX
.
Group Average
.
Proximity Matrix
Distance Between Centroids
Other methods driven by an objective
function
– Ward
Ward’s
s Method uses squared error
...
How to Define Inter-Cluster Similarity
p1
p2
p3
p4 p5
p1
p2
p3
p4
z
z
z
z
z
p5
MIN
.
MAX
.
Group Average
.
Proximity Matrix
Distance Between Centroids
Other methods driven by an objective
function
– Ward
Ward’s
s Method uses squared error
...
How to Define Inter-Cluster Similarity
p1
p2
p3
p4 p5
p1
×
×
p2
p3
p4
z
z
z
z
z
p5
MIN
.
MAX
.
Group Average
.
Proximity Matrix
Distance Between Centroids
Other methods driven by an objective
function
– Ward
Ward’s
s method uses squared error
...
Cluster Similarity: MIN or Single Link
z
Similarity of two clusters is based on the two
most similar (closest) points in the different
clusters
– Determined by one pair of points, i.e., by one link in
the proximity graph.
I1
I2
I3
I4
I5
I1
1.00
0.90
0.10
0.65
0 20
0.20
I2
0.90
1.00
0.70
0.60
0 50
0.50
I3
0.10
0.70
1.00
0.40
0 30
0.30
I4
0.65
0.60
0.40
1.00
0 80
0.80
I5
0.20
0.50
0.30
0.80
1 00
1.00
1
2
3
4
5
Hierarchical Clustering: MIN
1
5
3
5
0.2
2
1
2
3
0.15
6
0.1
0.05
4
4
Nested Clusters
0
3
6
2
5
Dendrogram
4
1
Strength of MIN
Original Points
• Can handle non-elliptical
p
shapes
p
Two Clusters
Limitations of MIN
Original Points
• Sensitive to noise and outliers
Two Clusters
Cluster Similarity: MAX or Complete Linkage
z
Similarity of two clusters is based on the two least
similar (most distant) points in the different
clusters
– Determined by all pairs of points in the two clusters
I1 I2 I3 I4
I1 1.00 0.90 0.10 0.65
I2 0.90 1.00 0.70 0.60
I3 0.10
0 10 0.70
0 0 1.00
1 00 0.40
0 40
I4 0.65 0.60 0.40 1.00
I5 0.20
0 20 0.50
0 50 0.30
0 30 0.80
0 80
I5
0.20
0.50
0 30
0.30
0.80
1 00
1.00
1
2
3
4
5
Hierarchical Clustering: MAX
4
1
2
5
5
0.4
0.35
03
0.3
2
0.25
3
3
6
1
4
0.2
0.15
0.1
0.05
0
Nested Clusters
3
6
4
Dendrogram
1
2
5
Strength of MAX
Original Points
• Less susceptible
p
to noise and outliers
Two Clusters
Limitations of MAX
Original Points
• Tends to break large clusters
• Biased towards globular clusters
Two Clusters
Cluster Similarity: Group Average
z
Proximity of two clusters is the average of pairwise proximity
between points in the two clusters.
∑ proximity(p , p )
i
proximity(Clusteri , Clusterj ) =
z
j
pi∈Clusteri
p j∈Clusterj
|Clusteri |∗|Clusterj |
Need to use average connectivity for scalability since total
proximity favors large clusters
I1
I2
I3
I4
I5
I1
1.00
0 90
0.90
0.10
0.65
0.20
I2
0.90
1 00
1.00
0.70
0.60
0.50
I3
0.10
0 70
0.70
1.00
0.40
0.30
I4
0.65
0 60
0.60
0.40
1.00
0.80
I5
0.20
0 50
0.50
0.30
0.80
1.00
1
2
3
4
5
Hierarchical Clustering: Group Average
5
4
1
0.25
2
5
0.2
2
0.15
3
6
1
4
3
Nested Clusters
0.1
0.05
0
3
6
4
1
Dendrogram
g
2
5
Hierarchical Clustering: Group Average
z
Compromise between Single and Complete
Link
z
St
Strengths
th
– Less susceptible to noise and outliers
z
Limitations
– Biased towards globular clusters
Cluster Similarity: Ward’s Method
z
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
z
Less susceptible to noise and outliers
z
Biased towards globular clusters
z
Hierarchical analogue of K-means
– Can be used to initialize K-means
K means
Hierarchical Clustering: Comparison
1
5
4
3
5
5
2
2
5
1
2
1
MIN
3
2
MAX
6
3
3
4
1
4
4
1
5
5
2
5
6
4
1
2
Ward’s Method
2
3
3
6
5
2
Group Average
3
1
4
4
6
1
4
3
Hierarchical Clustering: Problems and Limitations
z
Once a decision is made to combine two clusters,
it cannot be undone
z
No objective function is directly minimized
z
Different schemes have problems with one or
more off the
th following:
f ll i
– Sensitivity to noise and outliers
– Difficulty
Diffi lt handling
h dli diff
differentt sized
i d clusters
l t
and
d convex
shapes
– Breaking large clusters
Cluster Validity
z
For supervised classification we have a variety of
measures to evaluate how good our model is
– Accuracy,
Accuracy sensitivity,
sensitivity specificity
specificity...
z
For cluster analysis, the analogous question is how to
evaluate the “goodness”
goodness of the resulting clusters?
z
But “clusters are in the eye of the beholder”!
z
Then why do we want to evaluate them?
–
–
–
–
To avoid finding
gp
patterns in noise
To compare clustering algorithms
To compare two sets of clusters
To compare
p
two clusters
1
1
0.9
0.9
0.8
0.8
0.7
0.7
0.6
0.6
0.5
0.5
y
Random
Points
y
Clusters found in Random Data
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
0
1
DBSCAN
(densitybased)
0
0.2
0.4
x
1
1
0.9
0.9
0.8
0.8
0.7
0.7
0.6
0.6
0.5
0.5
y
y
K-means
0.4
0.4
0.3
0.3
0.2
0.2
01
0.1
01
0.1
0
0
0.2
0.4
0.6
x
0.6
0.8
1
x
0.8
1
0
Complete
Link
0
0.2
0.4
0.6
x
0.8
1
Different Aspects of Cluster Validation
1.
Determining the clustering tendency of a set of data, i.e.,
distinguishing whether non-random structure actually exists in the
data.
2.
Comparing the results of a cluster analysis to externally known
results, e.g., to externally given class labels.
3
3.
Evaluating how well the results of a cluster analysis fit the data
without reference to external information.
- Use only the data
4
4.
Comparing
C
i th
the results
lt off ttwo different
diff
t sets
t off cluster
l t analyses
l
to
t
determine which is better.
5.
Determining the ‘correct’ number of clusters.
For 2, 3, and 4, we can further distinguish whether we want to
evaluate the entire clustering or just individual clusters
clusters.
Measures of Cluster Validity
z
Numerical measures that are applied to judge various aspects
of cluster validity, are classified into the following three types.
– External Index: Used to measure the extent to which cluster labels
match externally supplied class labels.
‹
Entropy
– Internal Index: Used to measure the goodness of a clustering
structure without respect to external information.
‹
Sum of Squared Error (SSE)
– Relative Index: Used to compare two different clusterings or
clusters.
‹
z
Often an external or internal index is used for this function, e.g., SSE or
entropy
Sometimes these are referred to as criteria instead of indices
– However, sometimes criterion is the general strategy and index is the
numerical measure that implements the criterion.
Measuring Cluster Validity Via Correlation
z
z
Two matrices
–
Proximity Matrix
–
“Incidence”
Incidence Matrix
z
One row and one column for each data point
‹
An entry is 1 if the associated pair of points belong to the same cluster
‹
An entry is 0 if the associated pair of points belongs to different clusters
Compute the correlation between the two matrices
–
z
‹
Since the matrices are symmetric, only the correlation between
n(n-1) / 2 entries needs to be calculated.
High correlation indicates that points that belong to the
same cluster are close to each other.
Not a good measure for some density or contiguity based
clusters.
Measuring Cluster Validity Via Correlation
Correlation of incidence and proximity matrices
for the K-means
K means clusterings of the following two
data sets.
1
1
0.9
0.9
0.8
0.8
0.7
0.7
0.6
0.6
0.5
0.5
y
y
z
0.4
0.4
0.3
0.3
0.2
0.2
01
0.1
01
0.1
0
0
0.2
0.4
0.6
x
Corr = -0.9235
0.8
1
0
0
0.2
0.4
0.6
x
Corr = -0.5810
0.8
1
Using Similarity Matrix for Cluster Validation
Order the similarity matrix with respect to cluster
labels and inspect visually.
1
1
0.9
0.8
0.7
P
Points
0.6
y
z
0.5
0.4
0.3
0.2
0.1
0
10
0.9
20
08
0.8
30
0.7
40
0.6
50
0.5
60
0.4
70
0.3
80
0.2
90
0.1
100
0
0.2
0.4
0.6
x
0.8
1
20
40
60
Points
80
0
100Similarity
Using Similarity Matrix for Cluster Validation
z
Clusters in random data are not so crisp
1
10
0.9
0.9
20
0.8
0.8
30
07
0.7
07
0.7
40
0.6
0.6
50
0.5
0.5
60
0.4
0.4
70
0.3
0.3
80
0.2
0.2
90
0.1
0.1
100
20
40
60
80
0
100Similarity
Points
y
Points
1
0
0
0.2
0.4
0.6
x
DBSCAN
0.8
1
Using Similarity Matrix for Cluster Validation
z
Clusters in random data are not so crisp
1
10
0.9
0.9
20
0.8
0.8
30
0.7
0.7
40
0.6
0.6
50
0.5
0.5
60
0.4
0.4
70
0.3
0.3
80
0.2
0.2
90
0.1
0.1
100
20
40
60
80
0
100Similarity
y
Points
1
0
0
0.2
0.4
0.6
x
Points
K-means
0.8
1
Using Similarity Matrix for Cluster Validation
z
Clusters in random data are not so crisp
1
10
0.9
0.9
20
0.8
0.8
30
07
0.7
07
0.7
40
0.6
0.6
50
0.5
0.5
60
0.4
0.4
70
0.3
0.3
80
0.2
0.2
90
0.1
0.1
100
20
40
60
80
0
100Similarity
y
Points
1
0
0
Points
0.2
0.4
0.6
x
Complete Link
0.8
1
Using Similarity Matrix for Cluster Validation
1
0.9
500
1
2
0.8
6
0.7
1000
3
0.6
4
1500
0.5
0.4
2000
0.3
5
02
0.2
2500
0.1
7
3000
DBSCAN
500
1000
1500
2000
2500
3000
0
Internal Measures: SSE
z
Clusters in more complicated figures aren’t well separated
z
Internal Index: Used to measure the goodness of a clustering
structure without respect to external information
– SSE
z
SSE is g
good for comparing
p
g two clusterings
g or two clusters
(average SSE).
Can also be used to estimate the number of clusters
10
9
6
8
4
7
6
2
SSE
E
z
0
5
4
-2
3
2
-4
1
-6
0
5
10
15
2
5
10
15
K
20
25
30
Internal Measures: SSE
z
SSE curve for a more complicated data set
1
2
6
3
4
5
7
SSE of clusters found using K-means