View source: R/knn_classifier.R
knn_classifier | R Documentation |
knn_classifier
returns the predictions for a test set concerning a
nearest neighbours-based classifier.
knn_classifier(dataset, classes, index_test, distance, k, ...)
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. |
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.
The class labels for the elements in the test set.
Ángel López-Oriona, José A. Vilar
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.