Docsity

Hierarchical & K-Means Clustering: Similarity, Algorithms & Cluster Number Selection, Study notes of Computer Science

Partial preview of the text

Download Hierarchical & K-Means Clustering: Similarity, Algorithms & Cluster Number Selection and more Study notes Computer Science in PDF only on Docsity!

  • Lecture 17nd Nov

HAC Algorithm Start with all objects in their own cluster.Until there is only one cluster:Among the current clusters, determine the twoclusters,^ c and^ c , that are most similar. i^ j Replace c and^ c with a single cluster i^ j^

c ∪^ ci^ j

Problem : our similarity function computessimilarity between instances, but we also needto compute similarity between clusters.How?

Example: Clustering geneexpression data

Dendrogram

Comments on HAC• HAC is a fast tool that often provides interesting views ofa dataset• Primarily HAC can be viewed as an intuitively appealingclustering procedure for data analysis/exploration• We can create clusterings of different granularity bystopping at different levels of the dendrogram• HAC often used together with visualization of thedendrogram to decide how many clusters exist in thedata

Basic idea

-^ Typically assume the number of desired clusters,

k , is

given• Randomly choose

k^ examples as

seeds , one per cluster.

-^ Form initial clusters based on these seeds.•^ Iterate, repeatedly reallocating instances to differentclusters to improve the overall clustering.•^ Stop when clustering converges or after a fixed numberof iterations.

Mean-Squared Error Objective• Assume instances are real-valued vectors• Given a clustering of the data into k clusters, we cancompute the centroid of each cluster• If we use the mean of each cluster to represent all datapoints in the cluster, our mean squared error (MSE) is:• The objective of clustering is to find a clustering thatminimizes this error.

K-Means Example

(K=2)

K-Means Example

(K=2)^ Pick seeds

K-Means Example

(K=2)^ Pick seedsReassign clustersCompute centroids

x

x

K-Means Example

(K=2)^ Pick seedsReassign clustersCompute centroids

x

Reasssign clustersx

K-Means Example

(K=2)^ Pick seedsReassign clustersCompute centroids

x

Reasssign clustersxx x^ xx

Compute centroidsReassign clusters

K-Means Example

(K=2)^ Pick seedsReassign clustersCompute centroids

x

Reasssign clustersxx x^ xx

Compute centroidsReassign clustersConverged!

Proof of monoticity• Given a current set of clusters with their means, the MSEis given by :• Consider the reassignment step:– Since each point is only reassigned if it is closer to some othercluster than its current cluster, so we know the reassignmentstep will only decrease MSE• Consider the re-center step:– From our lemma we know that

μ’ minimizes the distortion of ci

’i

which implies that the resulting MSE again is decreased.• Combine the above two, we know Kmeans alwaysdecreases the MSE

Kmeans properties• Kmeans always converges in a finite number of steps– Typically converges very fast (in fewer iterations than thenumber of points)• Time complexity:– Assume computing distance between two instances is O(

d )

where^ d^ is the dimensionality of the vectors.– Reassigning clusters: O(

kn ) distance computations, or O(

knd ).

  • Computing centroids: Each instance vector gets added once tosome centroid: O(

nd ).

  • Assume these two steps are each done once for

I^ iterations: O( Iknd ). – Linear in all relevant factors, assuming a fixed number ofiterations, more efficient than O(n

2 ) HAC.

Good news!