knn_classifier {mlmts} | R Documentation |
Constructs a nearest neighbours-based classifier and returns the predictions for a test set
Description
knn_classifier
returns the predictions for a test set concerning a
nearest neighbours-based classifier.
Usage
knn_classifier(dataset, classes, index_test, distance, k, ...)
Arguments
dataset |
A list of MTS (numerical matrices). |
classes |
A vector containing the class labels associated with the
elements in |
index_test |
The indexes associated with the test elements in |
distance |
The corresponding distance measure to compute the nearest neighbours-based classifier (must be one the functions implemented in mlmts, as a string). |
k |
The number of neighbours. |
... |
Additional parameters for the function with respect to the considered distance. |
Details
Given a collection of MTS containing the training and test set, the function constructs a nearest neighbours-based classifier based on a given dissimilarity measure. The corresponding predictions for the elements in the test set are returned.
Value
The class labels for the elements in the test set.
Author(s)
Ángel López-Oriona, José A. Vilar
Examples
predictions_1_nn <- knn_classifier(BasicMotions$data[1 : 10], BasicMotions$classes[1 : 10],
index_test = 6 : 10, distance = 'dis_modwt', k = 1) # Computing the
# predictions for the test elements in dataset BasicMotions according to
# a 1-nearest neighbour classifier based on dis_modtw.
predictions_1_nn