R: 1NN classification for a pair of train/test time series...

OneNN {TSdist} | R Documentation

## 1NN classification for a pair of train/test time series datasets.

### Description

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.

### Usage

    OneNN(train, trainc, test, testc, distance, ...)

### Arguments

`train` | Time series database saved in a numeric matrix, a list, an `mts` object, a `zoo` object or `xts` object.
`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 `mts` object, a `zoo` object or `xts` object.
`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: `"euclidean"`, `"manhattan"`, `"minkowski"`, `"infnorm"`, `"ccor"`, `"sts"`, `"dtw"`, `"keogh_lb"`, `"edr"`, `"erp"`, `"lcss"`, `"fourier"`, `"tquest"`, `"dissimfull"`, `"dissimapprox"`, `"acf"`, `"pacf"`, `"ar.lpc.ceps"`, `"ar.mah"`, `"ar.mah.statistic"`, `"ar.mah.pvalue"`, `"ar.pic"`, `"cdm"`, `"cid"`, `"cor"`, `"cort"`, `"wav"`, `"int.per"`, `"per"`, `"mindist.sax"`, `"ncd"`, `"pred"`, `"spec.glk"`, `"spec.isd"`, `"spec.llr"`, `"pdc"`, `"frechet"`)
`...` | Additional parameters required by the chosen distance measure.

### Details

This function is useful to evaluate the performance of different distance measures in the task of classification of time series.

### Value

`classes` | Numerical vector providing the predicted class values for the series in the test set.
`error` | Error obtained in the 1NN classification process.

### Author(s)

Usue Mori, Alexander Mendiburu, Jose A. Lozano.

### See Also

To calculate the distance matrices of time series databases the `TSDatabaseDistances` is used.

### Examples

    # 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")

[Package TSdist version 3.6 Index]