Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions R/computeDistMat.R
Original file line number Diff line number Diff line change
Expand Up @@ -306,36 +306,36 @@ computeDistMat = function(x, y = NULL,
# Dynamic Time Warping Distance from rucrdtw package
if (method == "rucrdtw") {
requirePackages("rucrdtw")
ucrdtw = function(x, y, dtwwindow = 0.05, ...) {
proxy::pr_DB$set_entry(FUN = function(x, y, dtwwindow = 0.05, ...) {
rucrdtw::ucrdtw_vv(x, y, skip = TRUE, dtwwindow = dtwwindow, ...)$distance
}
pr_DB$set_entry(FUN = ucrdtw, names = "rucrdtw",
loop = TRUE, type = "metric",
description = "Dynamic Time Warping from UCR",
reference = "Boersch-Supan (2016). rucrdtw: Fast time series subsequence search in R.
The Journal of Open Source Software URL http://doi.org/10.21105/joss.00100;
Rakthanmanon et al. (2012). Searching and mining trillions of time series subsequences
under dynamic time warping. SIGKDD URL http://doi.org/10.1145/2339530.2339576",
formula = "minimum of sum(x[xw[i]]-y[yw[i]]) over all monotonic xw, yw");

return(as.matrix(proxy::dist(x, y, method = "rucrdtw", ...)))
},
names = "rucrdtw",
loop = TRUE, type = "metric",
description = "Dynamic Time Warping from UCR",
reference = "Boersch-Supan (2016). rucrdtw: Fast time series subsequence search in R.
The Journal of Open Source Software URL http://doi.org/10.21105/joss.00100;
Rakthanmanon et al. (2012). Searching and mining trillions of time series subsequences
under dynamic time warping. SIGKDD URL http://doi.org/10.1145/2339530.2339576",
formula = "minimum of sum(x[xw[i]]-y[yw[i]]) over all monotonic xw, yw");
return(as.matrix(proxy::dist(x, y, method = "rucrdtw", ...)))
}
# Euclidean Distance from rucrdtw package
if (method == "rucred") {
requirePackages("rucrdtw")
ucred = function(x, y, ...) {
proxy::pr_DB$set_entry(
FUN = function(x, y, ...) {
rucrdtw::ucred_vv(data = x, query = y, skip = TRUE, ...)$distance
}
pr_DB$set_entry(FUN = ucred, names = "rucred",
loop = TRUE, type = "metric",
description = "Euclidean Distance from UCR",
reference = "Boersch-Supan (2016). rucrdtw: Fast time series subsequence search in R.
The Journal of Open Source
Software URL http://doi.org/10.21105/joss.00100;
Rakthanmanon et al. (2012). Searching and mining trillions of time series subsequences
under dynamic time
warping. SIGKDD URL http://doi.org/10.1145/2339530.2339576",
formula = "sqrt(sum((x-y)^2))");
},
names = "rucred",
loop = TRUE, type = "metric",
description = "Euclidean Distance from UCR",
reference = "Boersch-Supan (2016). rucrdtw: Fast time series subsequence search in R.
The Journal of Open Source
Software URL http://doi.org/10.21105/joss.00100;
Rakthanmanon et al. (2012). Searching and mining trillions of time series subsequences
under dynamic time
warping. SIGKDD URL http://doi.org/10.1145/2339530.2339576",
formula = "sqrt(sum((x-y)^2))");

return(as.matrix(proxy::dist(x, y, method = "rucred", ..., PACKAGE = "rucrdtw")))
}
Expand Down
18 changes: 9 additions & 9 deletions R/metricChoices.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ metricChoices = function(proxy.only = FALSE) {
proxy.list = proxy::pr_DB$get_entries()
is_metric = unlist(BBmisc::extractSubList(proxy.list, element = "type")) == "metric"
proxy_metric_names = unlist(BBmisc::extractSubList(proxy.list[is_metric],
element = "names"))
element = "names"))
if (proxy.only) {
return(proxy_metric_names)
} else {
return(c(proxy_metric_names,
"shortEuclidean", "mean", "relAreas",
"jump", "globMax", "globMin",
"points", "custom.metric",
"amplitudeDistance", "phaseDistance",
"FisherRao", "elasticMetric",
"elasticDistance",
"dtwPath", "rucrdtw", "rucred"))
additional_metric_names = c("shortEuclidean", "mean", "relAreas",
"jump", "globMax", "globMin", "points", "custom.metric",
"amplitudeDistance", "phaseDistance", "FisherRao", "elasticMetric",
"elasticDistance", "dtwPath", "rucrdtw", "rucred")
names(additional_metric_names) = additional_metric_names
choices = c(proxy_metric_names, additional_metric_names)
# Make sure we have unique names
return(choices[unique(names(choices))])
}
}