Data Mining�Cluster Analysis: Basic Concepts �and Algorithms
Module 5
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 1
What is Cluster Analysis?
Inter-cluster distances are maximized
Intra-cluster distances are minimized
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 2
Applications of Cluster Analysis
Clustering precipitation in Australia
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 3
What is not Cluster Analysis?
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 4
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 5
Types of Clusterings
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 6
Partitional Clustering
Original Points
A Partitional Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 7
Hierarchical Clustering
Traditional Hierarchical Clustering
Non-traditional Hierarchical Clustering
Non-traditional Dendrogram
Traditional Dendrogram
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 8
Other Distinctions Between Sets of Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 9
Types of Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 10
Types of Clusters: Well-Separated
3 well-separated clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 11
Types of Clusters: Center-Based
4 center-based clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 12
Types of Clusters: Contiguity-Based
8 contiguous clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 13
Types of Clusters: Density-Based
6 density-based clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 14
Types of Clusters: Conceptual Clusters
.
2 Overlapping Circles
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 15
Types of Clusters: Objective Function
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 16
Types of Clusters: Objective Function …
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 17
Characteristics of the Input Data Are Important
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 18
Clustering Algorithms
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 19
K-means Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 20
K-means Clustering – Details
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 21
Two different K-means Clusterings
Sub-optimal Clustering
Optimal Clustering
Original Points
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 22
Importance of Choosing Initial Centroids
© 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
Evaluating K-means Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 25
Importance of Choosing Initial Centroids …
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 26
Importance of Choosing Initial Centroids …
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 27
Problems with Selecting Initial Points
���
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 28
10 Clusters Example
Starting with two initial centroids in one cluster of each pair of clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 29
10 Clusters Example
Starting with two initial centroids in one cluster of each pair of clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 30
10 Clusters Example
Starting with some pairs of clusters having three initial centroids, while other have only one.
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 31
10 Clusters Example
Starting with some pairs of clusters having three initial centroids, while other have only one.
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 32
Solutions to Initial Centroids Problem
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 33
Handling Empty Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 34
Updating Centers Incrementally
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 35
Pre-processing and Post-processing
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 36
Bisecting K-means
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 37
Bisecting K-means Example
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 38
Limitations of K-means
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 39
Limitations of K-means: Differing Sizes
Original Points
K-means (3 Clusters)
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 40
Limitations of K-means: Differing Density
Original Points
K-means (3 Clusters)
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 41
Limitations of K-means: Non-globular Shapes
Original Points
K-means (2 Clusters)
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 42
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 43
Overcoming K-means Limitations
Original Points K-means Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 44
Overcoming K-means Limitations
Original Points K-means Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 45
Hierarchical Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 46
Strengths of Hierarchical Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 47
Hierarchical Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 48
Agglomerative Clustering Algorithm
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 49
Starting Situation
p1
p3
p5
p4
p2
p1
p2
p3
p4
p5
. . .
.
.
.
Proximity Matrix
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 50
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 51
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 52
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 53
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 54
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 55
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 56
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 57
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 58
Cluster Similarity: MIN or Single Link
1
2
3
4
5
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 59
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 60
Strength of MIN
Original Points
Two Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 61
Limitations of MIN
Original Points
Two Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 62
Cluster Similarity: MAX or Complete Linkage
1
2
3
4
5
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 63
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 64
Strength of MAX
Original Points
Two Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 65
Limitations of MAX
Original Points
Two Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 66
Cluster Similarity: Group Average
1
2
3
4
5
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 67
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 68
Hierarchical Clustering: Group Average
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 69
Cluster Similarity: Ward’s Method
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 70
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 71
Hierarchical Clustering: Time and Space requirements
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 72
Hierarchical Clustering: Problems and Limitations
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 73
MST: Divisive Hierarchical Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 74
MST: Divisive Hierarchical Clustering
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 75
DBSCAN
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 76
DBSCAN: Core, Border, and Noise Points
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 77
DBSCAN Algorithm
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 78
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 79
When DBSCAN Works Well
Original Points
Clusters
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 80
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 81
DBSCAN: Determining EPS and MinPts
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 82
Cluster Validity
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 83
Clusters found in Random Data
Random Points
K-means
DBSCAN
Complete Link
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 84
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 85
Measures of Cluster Validity
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 86
Measuring Cluster Validity Via Correlation
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 87
Measuring Cluster Validity Via Correlation
Corr = -0.9235
Corr = -0.5810
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 88
Using Similarity Matrix for Cluster Validation
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 89
Using Similarity Matrix for Cluster Validation
DBSCAN
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 90
Using Similarity Matrix for Cluster Validation
K-means
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 91
Using Similarity Matrix for Cluster Validation
Complete Link
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 92
Using Similarity Matrix for Cluster Validation
DBSCAN
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 93
Internal Measures: SSE
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 94
Internal Measures: SSE
SSE of clusters found using K-means
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 95
Framework for Cluster Validity
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 96
Statistical Framework for SSE
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 97
Statistical Framework for Correlation
Corr = -0.9235
Corr = -0.5810
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 98
Internal Measures: Cohesion and Separation
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 99
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 100
Internal Measures: Cohesion and Separation
cohesion
separation
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 101
Internal Measures: Silhouette Coefficient
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 102
External Measures of Cluster Validity: Entropy and Purity
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 103
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 104