K-means clustering

K-means clustering is one of the most commonly utilized clustering algorithms in machine learning. K-means attempts to identify the underlying patterns of datapoints in a dataset. In K-means, we define k as the number of centroids (the center of an object with uniform density) that our cluster has. Then, we categorize the different datapoints with respect to those centroids.

We can use the K-means library, which can be found at https://github.com/muesli/kmeans, in order to perform K-means clustering on a dataset. Let's take a look:

  1. First, we instantiate the main package and import our required packages:
package mainimport (  "fmt"  "log"  "math/rand"  "github.com/muesli/clusters"  "github.com/muesli/kmeans")
  1. Next, we create ...

Get Hands-On High Performance with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.