Clustering is the unsupervised version of classification where the grouping of data into categories is based on some metric of similarity or distance. This section will use k-means clustering, which is the most famous clustering technique and one that is also easy to implement. Once again, we are going to use an external library that can be found at https://github.com/mash/gokmeans.
The utility that showcases clustering in Go is called cluster.go, and it is going to be presented in three parts. The utility requires one command-line argument, which is the number of clusters that are going to be created.
The first part of cluster.go is as follows:
package main import ( "flag" "fmt" "github.com/mash/gokmeans" "strconv" ) var observations []gokmeans.Node = []gokmeans.Node{ gokmeans.Node{4}, gokmeans...