K-Means Algorithm
Initialize K centroids randomly: Choose K random data points from the dataset to serve as the initial centroids.
Repeat until convergence: The algorithm iterates until the centroids no longer move significantly, or a maximum number of iterations is reached.
Assign each data point to its nearest centroid: For each data point in the dataset, calculate the distance between the point and each of the K centroids. Assign the data point to the centroid with the smallest distance.
Recalculate the centroid of each cluster: After all data points have been assigned to a centroid, calculate the mean position of all the data points assigned to each centroid. This new mean position becomes the new centroid for that cluster.
Repeat steps 3 and 4 until convergence, meaning the centroids no longer move significantly
between iterations, or a maximum number of iterations is reached.
Repeat until we get the lowest sum of variance and pick those clusters as our result.
Comments
Post a Comment