Algorithm

The K-means algorithm is so simple that we can quickly write it in 100 lines of code. The algorithm goes through the following steps to reach its goal:

  1. First, it picks up data points from the samples as initial centroids.
  2. Then, it assigns each sample to the closest centroid () using the following formula:
  3. Next, it updates the centroids so that they are at the center of the new clusters being led by the new cluster assignment.
  4. Repeat steps 2-3 until the cluster assignment remains unchanged or reaches the maximum number of iterations. ...

Get Hands-On Machine Learning with TensorFlow.js now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.