Blog

K-Means clustering : The Definitive Guide

k-mean clustering

K-means clustering is one of the simple and most used unsupervised machine learning algorithms which is useful for a top SEO agency. The goal of this algorithm is to find groups in the data, with the number of groups represented by the variable K.

Algorithm 

  1. Clusters the data into k groups where k is predefined.

  2. Select k points at random as cluster centers.

  3. Assign objects to their closest cluster center according to the Euclidean distance function.

  4. Calculate the centroid or mean of all objects in each cluster.

  5. Repeat steps 2, 3 and 4 until the same points are assigned to each cluster in consecutive rounds.

Loading libraries:

k mean 1

Loading Stop-words:

k mean 2

Fetching the files and clearing them:

k mean 3

Creating term document matrix:

k mean 4

Performing the cluster:

k mean 5

Output:

k mean 6

  •  
  •  
  •  
  •  

Leave a Reply

Your email address will not be published. Required fields are marked *