Last chance! 50% off unlimited learning
Sale ends in
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, ...)
Time series database saved in a numeric matrix, a list, an mts
object, a zoo
object or xts
object.
Numerical vector which indicates the class of each of the series in the training set.
Time series database saved in a numeric matrix, a list, an mts
object, a zoo
object or xts
object.
Numerical vector which indicates the class of each of the series in the testing set.
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.
Numerical vector providing the predicted class values for the series in the test set.
Error obtained in the 1NN classification process.
This function is useful to evaluate the performance of different distance measures in the task of classification of time series.
To calculate the distance matrices of time series databases the TSDatabaseDistances
is used.
# NOT RUN {
# 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")
# }
Run the code above in your browser using DataLab