Data Mining and Machine Learning (CSE 321)
Topic – 8: Cluster Analysis
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 1
Topic Contents
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 2
Recommended Reading
3
3
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 3
What is Cluster Analysis?
Inter-cluster distances are maximized
Intra-cluster distances are minimized
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 4
Applications of Cluster Analysis
Clustering precipitation in Australia
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 5
Notion of a Cluster can be Ambiguous
How many clusters?
Four Clusters
Two Clusters
Six Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 6
Types of Clusterings
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 7
Partitional Clustering
Original Points
A Partitional Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 8
Hierarchical Clustering
Traditional Hierarchical Clustering
Traditional Dendrogram
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 9
Other Distinctions Between Sets of Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 10
Types of Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 11
Types of Clusters: Well-Separated
3 well-separated clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 12
Types of Clusters: Center-Based
4 center-based clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 13
Types of Clusters: Contiguity-Based
8 contiguous clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 14
Types of Clusters: Density-Based
6 density-based clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 15
Types of Clusters: Conceptual Clusters
.
2 Overlapping Circles
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 16
Clustering Algorithms
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 17
K-means Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 18
K-means Clustering – Details
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 19
Two different K-means Clusterings
Sub-optimal Clustering
Optimal Clustering
Original Points
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 20
Importance of Choosing Initial Centroids
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 21
Importance of Choosing Initial Centroids
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 22
Evaluating K-means Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 23
Importance of Choosing Initial Centroids …
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 24
Importance of Choosing Initial Centroids …
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 25
Solutions to Initial Centroids Problem
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 26
Handling Empty Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 27
Updating Centers Incrementally
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 28
Pre-processing and Post-processing
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 29
Bisecting K-means
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 30
Bisecting K-means Example
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 31
Limitations of K-means
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 32
Limitations of K-means: Differing Sizes
Original Points
K-means (3 Clusters)
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 33
Limitations of K-means: Differing Density
Original Points
K-means (3 Clusters)
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 34
Limitations of K-means: Non-globular Shapes
Original Points
K-means (2 Clusters)
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 35
Overcoming K-means Limitations
Original Points K-means Clusters
One solution is to use many clusters.
Find parts of clusters, but need to put together.
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 36
Overcoming K-means Limitations
Original Points K-means Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 37
Overcoming K-means Limitations
Original Points K-means Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 38
Hierarchical Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 39
Strengths of Hierarchical Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 40
Hierarchical Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 41
Agglomerative Clustering Algorithm
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 42
Starting Situation
p1
p3
p5
p4
p2
p1
p2
p3
p4
p5
. . .
.
.
.
Proximity Matrix
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 43
Intermediate Situation
C1
C4
C2
C5
C3
C2
C1
C1
C3
C5
C4
C2
C3
C4
C5
Proximity Matrix
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 44
Intermediate Situation
C1
C4
C2
C5
C3
C2
C1
C1
C3
C5
C4
C2
C3
C4
C5
Proximity Matrix
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 45
After Merging
C1
C4
C2 U C5
C3
? ? ? ?
?
?
?
C2 U C5
C1
C1
C3
C4
C2 U C5
C3
C4
Proximity Matrix
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 46
How to Define Inter-Cluster Similarity
p1
p3
p5
p4
p2
p1
p2
p3
p4
p5
. . .
.
.
.
Similarity?
Proximity Matrix
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 47
How to Define Inter-Cluster Similarity
p1
p3
p5
p4
p2
p1
p2
p3
p4
p5
. . .
.
.
.
Proximity Matrix
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 48
How to Define Inter-Cluster Similarity
p1
p3
p5
p4
p2
p1
p2
p3
p4
p5
. . .
.
.
.
Proximity Matrix
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 49
How to Define Inter-Cluster Similarity
p1
p3
p5
p4
p2
p1
p2
p3
p4
p5
. . .
.
.
.
Proximity Matrix
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 50
How to Define Inter-Cluster Similarity
p1
p3
p5
p4
p2
p1
p2
p3
p4
p5
. . .
.
.
.
Proximity Matrix
×
×
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 51
Cluster Similarity: MIN or Single Link
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 52
Hierarchical Clustering: MIN
Nested Clusters
Dendrogram
1
2
3
4
5
6
1
2
3
4
5
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 53
Strength of MIN
Original Points
Two Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 54
Limitations of MIN
Original Points
Two Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 55
Cluster Similarity: MAX or Complete Linkage
1
2
3
4
5
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 56
Hierarchical Clustering: MAX
Nested Clusters
Dendrogram
1
2
3
4
5
6
1
2
5
3
4
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 57
Strength of MAX
Original Points
Two Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 58
Limitations of MAX
Original Points
Two Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 59
Cluster Similarity: Group Average
1
2
3
4
5
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 60
Hierarchical Clustering: Group Average
Nested Clusters
Dendrogram
1
2
3
4
5
6
1
2
5
3
4
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 61
Hierarchical Clustering: Group Average
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 62
Cluster Similarity: Ward’s Method
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 63
Hierarchical Clustering: Comparison
Group Average
Ward’s Method
1
2
3
4
5
6
1
2
5
3
4
MIN
MAX
1
2
3
4
5
6
1
2
5
3
4
1
2
3
4
5
6
1
2
5
3
4
1
2
3
4
5
6
1
2
3
4
5
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 64
Hierarchical Clustering: Time and Space requirements
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 65
Hierarchical Clustering: Problems and Limitations
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 66
MST: Divisive Hierarchical Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 67
MST: Divisive Hierarchical Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 68
DBSCAN
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 69
DBSCAN: Core, Border, and Noise Points
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 70
DBSCAN: Determining EPS and MinPts
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 71
DBSCAN Algorithm
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 72
DBSCAN: Core, Border and Noise Points
Original Points
Point types: core, border and noise
Eps = 10, MinPts = 4
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 73
When DBSCAN Works Well
Original Points
Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 74
When DBSCAN Does NOT Work Well
Original Points
(MinPts=4, Eps=9.75).
(MinPts=4, Eps=9.92)
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 75
Cluster Validity
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 76
Clusters found in Random Data
Random Points
K-means
DBSCAN
Complete Link
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 77
Different Aspects of Cluster Validation
- Use only the data
For 2, 3, and 4, we can further distinguish whether we want to evaluate the entire clustering or just individual clusters.
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 78
Measures of Cluster Validity
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 79
Measuring Cluster Validity Via Correlation
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 80
Measuring Cluster Validity Via Correlation
Corr = -0.9235
Corr = -0.5810
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 81
Using Similarity Matrix for Cluster Validation
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 82
Using Similarity Matrix for Cluster Validation
DBSCAN
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 83
Using Similarity Matrix for Cluster Validation
K-means
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 84
Using Similarity Matrix for Cluster Validation
Complete Link
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 85
Using Similarity Matrix for Cluster Validation
DBSCAN
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 86
Internal Measures: SSE
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 87
Internal Measures: SSE
SSE of clusters found using K-means
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 88
Framework for Cluster Validity
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 89
Statistical Framework for SSE
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 90
Statistical Framework for Correlation
Corr = -0.9235
Corr = -0.5810
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 91
Internal Measures: Cohesion and Separation
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 92
Internal Measures: Cohesion and Separation
1
2
3
4
5
×
×
×
m1
m2
m
K=2 clusters:
K=1 cluster:
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 93
Internal Measures: Cohesion and Separation
cohesion
separation
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 94
Internal Measures: Silhouette Coefficient
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 95
External Measures of Cluster Validity: Entropy and Purity
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 96
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
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 97