With the kNN algorithm
The Shogun library also has an implementation of the kNN algorithm, and it is placed in the CKNN class. Before using this algorithm, we have to calculate the distance between all features in the training dataset. This operation can be done, for example, with the instance of the CEuclideanDistance class (or an alternative), which implements the CDistance interface. There are many distance implementation classes in the Shogun library, such as cosine similarity, and Manhattan and Hamming distances. After we have the object containing the distances for our training set, we can initialize the object of the CKNN class, which takes the distance object, training labels, and the k parameter (which is the number of searched-for ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access