OneNN | R Documentation |
Given a specific distance measure, this function provides the 1NN classification values and the associated error for a specific train/test pair of time series databases.
OneNN(train, trainc, test, testc, distance, ...)
train |
Time series database saved in a numeric matrix, a list, an |
trainc |
Numerical vector which indicates the class of each of the series in the training set. |
test |
Time series database saved in a numeric matrix, a list, an |
testc |
Numerical vector which indicates the class of each of the series in the testing set. |
distance |
Distance measure to be used. It must be one of: |
... |
Additional parameters required by the chosen distance measure. |
This function is useful to evaluate the performance of different distance measures in the task of classification of time series.
classes |
Numerical vector providing the predicted class values for the series in the test set. |
error |
Error obtained in the 1NN classification process. |
Usue Mori, Alexander Mendiburu, Jose A. Lozano.
To calculate the distance matrices of time series databases the TSDatabaseDistances
is used.
# The example.database2 synthetic database is loaded data(example.database2) # Create train/test by dividing the dataset 70%-30% set.seed(100) trainindex <- sample(1:100, 70, replace=FALSE) train <- example.database2[[1]][trainindex, ] test <- example.database2[[1]][-trainindex, ] trainclass <- example.database2[[2]][trainindex] testclass <- example.database2[[2]][-trainindex] # Apply the 1NN classifier for different distance measures OneNN(train, trainclass, test, testclass, "euclidean") OneNN(train, trainclass, test, testclass, "pdc")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.