Professional Documents
Culture Documents
Lecture5 - Clustering (K Means and K Medoids)
Lecture5 - Clustering (K Means and K Medoids)
Clustering is subjective
Similarity is
hard to define,
but…
“We know it
when we see it”
The real
meaning of
similarity is a
philosophical
question. We
will take a more
pragmatic
approach.
Defining Distance Measures
Definition: Let O1 and O2 be two objects from the
universe of possible objects. The distance
(dissimilarity) between O1 and O2 is a real number
denoted by D(O1,O2)
Peter Piotr
0.23 3 342.7
Common Distance Functions
Common Distance Functions
Common Distance Functions
Two Types of Clustering
• Partitional algorithms: Construct various partitions and then evaluate them by
some criterion (k-means, k-medoids).
•Hierarchical algorithms: Create a hierarchical decomposition of the set of
objects using some criterion (BIRCH, CAMELEON).
Hierarchica Partitional
l
K-MEANS
CLUSTERING
K-Means
Therefore, there is no
change in the cluster.
Thus, the algorithm comes
to a halt here and final
result consist of 2 clusters
{1,2} and {3,4,5,6,7}.
PLOT
(with K=3)
Step 1 Step 2
PLOT
K-MEDOIDS
CLUSTERING
What Is the Problem of the K-Means
Method?
10 10
9 9
8 8
7 7
6 6
5 5
4 4
3 3
2 2
1 1
0 0
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
PAM: A Typical K-Medoids Algorithm
Total Cost = 20
10 10 10
9 9 9
8 8 8
Arbitrary Assign
7 7 7
6 6 6
5
choose k 5 each 5
4 object as 4 remainin 4
3 initial 3
g object 3
2
medoids 2
to 2
nearest
1 1 1
0 0 0
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
medoids 0 1 2 3 4 5 6 7 8 9 10
Do loop
10 10
Compute
9 9
Swapping O
8 8
total cost of
Until no
7 7
and Oramdom 6
swapping 6
change
5 5
If quality is 4 4
improved. 3 3
2 2
1 1
0 0
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
27
K-Medoids Clustering Example
K-Medoids Clustering Example
PAM works effectively for small data sets, but does not scale well
for large data sets (due to the computational complexity)
H. Zha, C. Ding, M. Gu, X. He and H.D. Simon. "Spectral Relaxation for K-means
Clustering", Neural Information Processing Systems vol.14 (NIPS 2001). pp. 1057-
1064, Vancouver, Canada. Dec. 2001.
https://www.geeksforgeeks.org/ml-k-medoids-clustering-with-example/