0% found this document useful (0 votes)
18 views17 pages

Clustering Algorithms: K-Means

Uploaded by

Vishal13230
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views17 pages

Clustering Algorithms: K-Means

Uploaded by

Vishal13230
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Clustering Algorithms

1 K-means

2 Hierarchical Clustering

3 DBSCAN
Clustering Algorithms

1 K-means

The grouping of data points is done


considering the centroid of the clusters.

K=3
Clustering Algorithms

2 Hierarchical Clustering

The grouping is done based on


similarity between the data points
through a hierarchical diagram called a
dendrogram.
Clustering Algorithms

3 DBSCAN

The grouping of data points is done


based on the density of points.
K-means Algorithm
K-means Algorithm

K
K-means is an exclusive clustering method where
each data points belongs to a single cluster.

Number of groups or clusters


Working of Kmeans Algorithm
Working of K-means Algorithm

1 Choose the number of cluster k

The first step in k-means is to pick the


number of clusters, k. Let’s say we want
to have 3 clusters. Thus here, K = 3

K=3
Working of K-means Algorithm

C3
Select k random points from the
2
data as centroids C1

C2
Next, randomly select 3 data points to be
the centroid for each cluster. Each cluster
is represented by a centroid in Kmeans.

K=3
Working of K-means Algorithm

Assign all the points to the closest


3
cluster centroid

Once we initialize the centroids, the next


step is to assign each point to the closest
cluster centroid based on distance.

K=3
Working of K-means Algorithm

Assign all the points to the closest


3
cluster centroid

Once we initialize the centroids, the next


step is to assign each point to the closest
cluster centroid based on distance.

K=3
Working of K-means Algorithm

Recompute the centroids of newly


4
formed clusters

The next step is to compute the centroids


for the next iteration based on the newly
formed clusters

K=3
Working of K-means Algorithm

● The blue point is now closer to the


yellow centroid.
● The blue and the yellow centroids also
change.

K=3
Working of K-means Algorithm

● Now, the red point is closer to the blue


centroid after the new centroid is
calculated, thus this point also moves
to the blue cluster. Thus, the red
centroid also changes.

K=3
Working of K-means Algorithm

● With the addition of the new point, the


blue centroid now changes.

K=3
When should we stop
this process?
Working of K-means Algorithm

Stop iterating when the centroids of newly


formed clusters are not changing or after
a fixed number of iterations.

scikitlearn’s default iterations is 300

K=3

You might also like