diff --git a/R/computeDistMat.R b/R/computeDistMat.R index 5d537be..dc9940a 100644 --- a/R/computeDistMat.R +++ b/R/computeDistMat.R @@ -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"))) } diff --git a/R/metricChoices.R b/R/metricChoices.R index ac0a489..710cfef 100644 --- a/R/metricChoices.R +++ b/R/metricChoices.R @@ -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))]) } }