8 Cluster
8 Cluster
Goal of clustering:
Divide objects into groups and objects within a group
are more similar than those outside the group.
Clustering other objects
Clustering hand digits
Clustering is subjective
𝑛
• Euclidian distance: 𝑑 𝑥, 𝑦 = 𝑖=1(𝑥𝑖 − 𝑦𝑖 )2
𝑝 𝑛
• Minkowski distance: 𝑑 𝑥, 𝑦 = 𝑖=1(𝑥𝑖 − 𝑦𝑖 )𝑝
– Manhattan distance: p = 1, 𝑑 𝑥, 𝑦 = 𝑑𝑖=1 |𝑥𝑖 − 𝑦𝑖 |
– “inf”-distance: p = ∞, 𝑑 𝑥, 𝑦 = max(|𝑥𝑖 − 𝑦𝑖 |)
Example
Some problems with Euclidean
distance
Hamming Distance
• Manhattan distance is also called Hamming
distance when all features are binary
– Count the number of difference between two binary
vectors
– Example,𝑥, 𝑦 ∈ *0, 1+17
𝑑 𝑥, 𝑦 = 5
Edit distance
• Transform one of the objects into the other, and
measure how much effort it takes
𝑑 𝑥, 𝑦 = 5 ∗ 1 + 1 ∗ 3 + 2 ∗ 1 = 10
Outline
• Clustering
• Distance function
• K-means algorithm
• Analysis of K-means
Results of K-means clustering
𝑛
1
𝑚𝑖𝑛 | 𝑥𝑖 − 𝑐𝜋 𝑖 |2
𝑛
𝑖=1
Clustering is NP-Hard
• Find 𝑘 cluster centers, *𝑐1 , 𝑐 2 , … , 𝑐 𝑘 + ∈ 𝑅 𝑑 and assign each
data point to one cluster, 𝑛𝜋 𝑖 ∈ 1, … , 𝑘 , minimize
1
𝑚𝑖𝑛 | 𝑥 𝑖 − 𝑐 𝜋 𝑖 |2
𝑛
𝑖=1
• A search problem over the space of discrete assignments
– For all n data points together, there are 𝑘 𝑛 possibility
– The cluster assignment determines cluster centers.
An example
• For all n data points together, there are 𝑘 𝑛
possibilities, where k is the number of
clusters.
• An example:
– X={A, B, C}, n=3 (data points) k = 2 clusters
Convergence of K-Means
• Will K-Means objective oscillate?
𝑛
1
𝑚𝑖𝑛 | 𝑥𝑖 − 𝑐𝜋 𝑖 |2
𝑛
𝑖=1