May 2020
Intermediate to advanced
530 pages
17h 8m
English
The k-means algorithm in the Shogun library is implemented in the CKMeans class. The constructor of this class takes two parameters: the number of clusters and the object for distance measure calculation. In the following example, we will use the distance object defined with the CEuclideanDistance class. After we construct the object of the CKMeans type, we use the CKMeans::train() method to train our model on our training set, as follows:
Some<CDenseFeatures<DataType>> features; int num_clusters = 2; ... CEuclideanDistance* distance = new CEuclideanDistance(features, features); CKMeans* clustering = new CKMeans(num_clusters, distance); clustering->train(features);
When we have trained the k-means object, we ...
Read now
Unlock full access