diff --git a/.Rbuildignore b/.Rbuildignore index 11393e7..1739a09 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -13,4 +13,5 @@ ^README-.*\.png$ ^\.httr-oauth$ ^make\.R$ -^CONDUCT\.md$ +^CODE_OF_CONDUCT\.md$ +^\.github/ diff --git a/DESCRIPTION b/DESCRIPTION index 6feaaef..2f82f81 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,18 +1,21 @@ Package: tsmp Type: Package Title: Time Series with Matrix Profile -Version: 0.2.13.9004 +Version: 0.2.14.9009 Authors@R: c( person("Francisco", "Bischoff", email = "fbischoff@med.up.pt", role = c("aut", "cre"), comment = c(ORCID = "https://orcid.org/0000-0002-5301-8672")), - person("Michael", "Yeh", email = "myeh003@ucr.edu", role = c("res", "ccp", "ctb")) + person("Michael", "Yeh", email = "myeh003@ucr.edu", role = c("res", "ccp", "ctb"), comment = c(ORCID = "https://orcid.org/0000-0002-9807-2963")), + person("Diego", "Silva", email = "diegofs@ufscar.br", role = c("res", "ccp", "ctb"), comment = c(ORCID = "https://orcid.org/0000-0002-5184-9413")), + person("Yan", "Zhu", email = "yzhu015@ucr.edu", role = c("res", "ccp", "ctb")) ) Maintainer: Francisco Bischoff Description: A toolkit implementing the Matrix Profile concept that was created by CS-UCR . License: MIT + file LICENSE URL: https://github.com/franzbischoff/tsmp BugReports: https://github.com/franzbischoff/tsmp/issues -Depends: R (>= 2.10), beepr, doSNOW, parallel, foreach +Depends: R (>= 2.10), audio, doSNOW, parallel, foreach Encoding: UTF-8 +Language: en-US LazyData: true Roxygen: list(markdown = TRUE) RoxygenNote: 6.1.0 diff --git a/NAMESPACE b/NAMESPACE index 1721b2c..0617192 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ export(fast.movavg) export(fast.movsd) +export(find.chains) export(fluss) export(fluss.cac) export(fluss.extract) @@ -14,10 +15,11 @@ export(mstomp.par) export(sdts.f.score) export(sdts.predict) export(sdts.train) +export(simple.fast) export(stamp) export(stamp.par) export(unconstrain.search) -import(beepr) +import(audio) import(doSNOW) import(foreach) import(parallel) diff --git a/NEWS b/NEWS index 7ed38e8..5d9c893 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,12 @@ -tsmp 0.2.30 +tsmp 0.2.14 =========== +- Added SiMPle algorithm for sound data. +- Added FLUSS algorithm. +- Added \[find.chains()\] to look for chains primitives. +- Changed dependency from beepr to audio (actually beepr depends on + audio, so less dependencies) - Added a `NEWS.md` file to track changes to the package. tsmp 0.2.x diff --git a/NEWS.Rmd b/NEWS.Rmd index 3bba9df..fd0d548 100644 --- a/NEWS.Rmd +++ b/NEWS.Rmd @@ -21,8 +21,12 @@ knitr::opts_chunk$set( ) ``` -# tsmp 0.2.30 +# tsmp 0.2.14 +* Added SiMPle algorithm for sound data. +* Added FLUSS algorithm. +* Added [find.chains()] to look for chains primitives. +* Changed dependency from beepr to audio (actually beepr depends on audio, so less dependencies) * Added a `NEWS.md` file to track changes to the package. # tsmp 0.2.x diff --git a/NEWS.md b/NEWS.md index e5199ad..a162d02 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,12 +1,17 @@ NEWS ================ Francisco Bischoff -\- 18 Aug 2018 +\- 20 Aug 2018 -# tsmp 0.2.30 +# tsmp 0.2.14 + - Added SiMPle algorithm for sound data. + - Added FLUSS algorithm. + - Added \[find.chains()\] to look for chains primitives. + - Changed dependency from beepr to audio (actually beepr depends on + audio, so less dependencies) - Added a `NEWS.md` file to track changes to the package. # tsmp 0.2.x diff --git a/R/find_chains.R b/R/find_chains.R new file mode 100644 index 0000000..8daee93 --- /dev/null +++ b/R/find_chains.R @@ -0,0 +1,60 @@ +#' Find Time Series Chains +#' +#' Time Series Chains is a new primitive for time series data mining. +#' +#' @param matrices a result from STAMP or STOMP algorithms +#' +#' @return Returns `chains`, a `list` of chains founded with more than 2 patterns and `best` +#' with the best one. +#' @export +#' @references 1. Zhu Y, Imamura M, Nikovski D, Keogh E. Introducing time series chains: a new +#' primitive for time series data mining. Knowl Inf Syst. 2018 Jun 2;1–27. +#' @references Website: +#' @examples +#' w <- 50 +#' data <- gait_data +#' mp <- stamp(data, window.size = w, exclusion.zone = 1/4, verbose = 0) +#' find.chains(mp) +#' +find.chains <- function(matrices) { + size <- length(matrices$rpi) + chain.length <- rep(1, size) + chain.set <- list() + + k <- 1 + + for (i in 1:size) { + if (chain.length[i] == 1) { + j <- i + chain <- j + + while (matrices$rpi[j] > 0 && matrices$lpi[matrices$rpi[j]] == j) { + j <- matrices$rpi[j] + chain.length[j] <- -1 + chain.length[i] <- chain.length[i] + 1 + chain <- c(chain, j) + } + + if (length(chain) > 2) { + chain.set[[k]] <- chain + k <- k + 1 + } + } + } + + l <- max(chain.length) + + best.chain <- NULL + mean <- Inf + for (i in 1:length(chain.set)) { + if (length(chain.set[[i]]) == l) { + n <- mean(matrices$rmp[chain.set[[i]]]) + if (n < mean) { + mean <- n + best.chain <- chain.set[[i]] + } + } + } + + return(list(chains = chain.set, best = best.chain)) +} diff --git a/R/fluss.R b/R/fluss.R index 0169241..bc4ef17 100644 --- a/R/fluss.R +++ b/R/fluss.R @@ -125,7 +125,7 @@ fluss.extract <- function(arc.counts, num.segments, window.size, exclusion.zone #' Computes the arc count with edge correction (CAC). #' #' Original paper suggest using the classic statistical-process-control heuristic to set a threshold -#' where a semantic change may occur in CAC. This may be useful in realtime implementation as we don't +#' where a semantic change may occur in CAC. This may be useful in real-time implementation as we don't #' know in advance the number of domain changes to look for. Please check original paper (1). #' #' @param profile.index the profile index for arc counting. @@ -147,6 +147,7 @@ fluss.extract <- function(arc.counts, num.segments, window.size, exclusion.zone #' w <- 210 #' mp <- mstomp(data, w, verbose = 0) #' cac <- fluss.cac(mp$pi, w) +#' #' \dontrun{ #' data <- fluss_data$walkjogrun$data #' w <- fluss_data$walkjogrun$window # 80 diff --git a/R/gait_data.R b/R/gait_data.R new file mode 100644 index 0000000..085c369 --- /dev/null +++ b/R/gait_data.R @@ -0,0 +1,9 @@ +#' Original data used in the Time Series Chain demo +#' +#' @docType data +#' @format A `matrix` with 904 rows and 1 column with the Y data from an accelerometer +#' @source \url{https://sites.google.com/site/timeserieschain/} +#' +#' @references 1. Zhu Y, Imamura M, Nikovski D, Keogh E. Introducing time series chains: a new primitive for time series data mining. Knowl Inf Syst. 2018 Jun 2;1–27. +#' @keywords datasets +"gait_data" diff --git a/R/m_guide_search.R b/R/m_guide_search.R index 66afa67..c39ccf9 100644 --- a/R/m_guide_search.R +++ b/R/m_guide_search.R @@ -4,7 +4,7 @@ #' #' Although this functions handles Multivariate Time Series, it can also be used to handle Univariate Time Series. #' -#' @param data a `matrix` of `numeric`, where each colums is a time series. Accepts `vector` (see details), `list` and `data.frame` too. +#' @param data a `matrix` of `numeric`, where each column is a time series. Accepts `vector` (see details), `list` and `data.frame` too. #' @param window.size an `int` with the size of the sliding window. #' @param matrix.profile multidimensional matrix profile (matrix) #' @param profile.index multidimensional profile index (from [mstomp()] or [mstomp.par()]). diff --git a/R/m_unconstrain_search.R b/R/m_unconstrain_search.R index b9ab749..dbaf0ed 100644 --- a/R/m_unconstrain_search.R +++ b/R/m_unconstrain_search.R @@ -4,7 +4,7 @@ #' #' Although this functions handles Multivariate Time Series, it can also be used to handle Univariate Time Series. #' -#' @param data a `matrix` of `numeric`, where each colums is a time series. Accepts `vector` (see details), `list` and `data.frame` too. +#' @param data a `matrix` of `numeric`, where each column is a time series. Accepts `vector` (see details), `list` and `data.frame` too. #' @param window.size an `int` with the size of the sliding window. #' @param matrix.profile multidimensional matrix profile (from [mstomp()] or [mstomp.par()]). #' @param profile.index multidimensional profile index (from [mstomp()] or [mstomp.par()]). diff --git a/R/misc.R b/R/misc.R index eb55b28..370a4bc 100644 --- a/R/misc.R +++ b/R/misc.R @@ -70,9 +70,35 @@ fast.movavg <- function(data, n) { std <- function(x) { sdx <- stats::sd(x) - if (sdx == 0) + if (sdx == 0) { return(sdx) + } return(sqrt((length(x) - 1) / length(x)) * sdx) } +#' Play sound with `audio` +#' +#' @param data sound data provided by this package +#' +#' @keywords internal +#' @import audio +beep <- function(data) { + if (!(is.null(audio::audio.drivers()) || nrow(audio::audio.drivers()) == 0)) { + tryCatch({ + audio::play(data) + }, + error = function(cond) { + message("Failed to play audio alert") + message(cond) + invisible() + }, + warning = function(cond) { + message("Something went wrong playing audio alert") + message(cond) + invisible() + } + ) + } + invisible() +} diff --git a/R/mstomp.R b/R/mstomp.R index adeba8e..810f5ec 100644 --- a/R/mstomp.R +++ b/R/mstomp.R @@ -8,7 +8,7 @@ #' Although this functions handles Multivariate Time Series, it can also be used to handle Univariate Time Series. #' `verbose` changes how much information is printed by this function; `0` means nothing, `1` means text, `2` means text and sound. #' -#' @param data a `matrix` of `numeric`, where each colums is a time series. Accepts `vector` (see details), `list` and `data.frame` too. +#' @param data a `matrix` of `numeric`, where each column is a time series. Accepts `vector` (see details), `list` and `data.frame` too. #' @param window.size an `int` with the size of the sliding window. #' @param must.dim an `int` or `vector` of which dimensions to forcibly include (default is `NULL`). #' @param exc.dim an `int` or `vector` of which dimensions to exclude (default is `NULL`). @@ -114,7 +114,7 @@ mstomp <- function(data, window.size, must.dim = NULL, exc.dim = NULL, exclusion on.exit(close(pb)) } if (verbose > 1) { - on.exit(beepr::beep(), TRUE) + on.exit(beep(sounds[[1]]), TRUE) } ## initialization @@ -198,7 +198,7 @@ mstomp <- function(data, window.size, must.dim = NULL, exc.dim = NULL, exclusion if (n.dim > 1) { dist.pro.sort <- t(apply(distance.profile, 1, sort)) - } # sort by row, put all -Inf to the first columns + } # sort by row, put all -Inf to the first column else { dist.pro.sort <- distance.profile } diff --git a/R/mstomp_par.R b/R/mstomp_par.R index e4cef6a..a481426 100644 --- a/R/mstomp_par.R +++ b/R/mstomp_par.R @@ -8,7 +8,7 @@ #' Although this functions handles Multivariate Time Series, it can also be used to handle Univariate Time Series. #' `verbose` changes how much information is printed by this function; `0` means nothing, `1` means text, `2` means text and sound. #' -#' @param data a `matrix` of `numeric`, where each colums is a time series. Accepts `vector` (see details), `list` and `data.frame` too. +#' @param data a `matrix` of `numeric`, where each column is a time series. Accepts `vector` (see details), `list` and `data.frame` too. #' @param window.size an `int`. Size of the sliding window. #' @param must.dim an `int` or `vector` of which dimensions to forcibly include (default is `NULL`). #' @param exc.dim an `int` or `vector` of which dimensions to exclude (default is `NULL`). @@ -29,9 +29,8 @@ #' #' @examples #' # using all dimensions -#' Sys.sleep(1) # sometimes sleep is needed if you run parallel multiple times in a row #' mp <- mstomp.par(toy_data$data[1:100,], 30, verbose = 0) -#' @import beepr doSNOW foreach parallel +#' @import doSNOW foreach parallel mstomp.par <- function(data, window.size, must.dim = NULL, exc.dim = NULL, exclusion.zone = 1 / 2, verbose = 2, n.workers = 2) { eps <- .Machine$double.eps^0.5 @@ -140,7 +139,7 @@ mstomp.par <- function(data, window.size, must.dim = NULL, exc.dim = NULL, exclu on.exit(close(pb), TRUE) } if (verbose > 1) { - on.exit(beepr::beep(), TRUE) + on.exit(beep(sounds[[1]]), TRUE) } ## initialize variable diff --git a/R/sdts_predict.R b/R/sdts_predict.R index 757c633..7512acf 100644 --- a/R/sdts_predict.R +++ b/R/sdts_predict.R @@ -87,7 +87,7 @@ sdts.predict <- function(model, data, window.size) { #' `beta` is used to balance F-score towards recall (`>1`) or precision (`<1`). #' #' @param gtruth a `vector` of `logical`. Ground truth annotation. -#' @param pred a `vector` of `logical`. Predictied annotation from [sdts.predict()] +#' @param pred a `vector` of `logical`. Predicted annotation from [sdts.predict()] #' @param beta a `numeric`. See details. (default is `1`). #' #' @return Returns a `list` with `f.score`, `precision` and `recall`. diff --git a/R/sdts_train.R b/R/sdts_train.R index 6fd35ff..0988d90 100644 --- a/R/sdts_train.R +++ b/R/sdts_train.R @@ -148,7 +148,7 @@ sdts.train <- function(data, label, window.size, beta = 1, pat.max = Inf, parall on.exit(close(pb)) } if (verbose > 1) { - on.exit(beepr::beep(), TRUE) + on.exit(beep(sounds[[1]]), TRUE) } for (i in 1:n.window.size) { @@ -342,7 +342,7 @@ sdts.train <- function(data, label, window.size, beta = 1, pat.max = Inf, parall #' @param beta a number that balance the F-Score. Beta > 1 towards recall, < towards precision #' @param window.size an integer with the sliding window size #' -#' @return Returns the best threashold and its F-Score +#' @return Returns the best threshold and its F-Score #' #' @keywords internal #' @@ -384,7 +384,7 @@ golden.section <- function(dist.pro, label, pos.st, pos.ed, beta, window.size) { #' @param window.size an integer with the sliding window size #' @param fit.idx an integer with the index of the current threshold #' -#' @return Returns the best threashold and its F-Score +#' @return Returns the best threshold and its F-Score #' #' @keywords internal diff --git a/R/simple.R b/R/simple.R new file mode 100644 index 0000000..62ddc4e --- /dev/null +++ b/R/simple.R @@ -0,0 +1,224 @@ +#' Compute the similarity join for Sound data. +#' +#' Compute the similarity join for Sound data. +#' +#' `verbose` changes how much information is printed by this function; `0` means nothing, `1` means text, `2` means text and sound. +#' +#' @param data a `matrix` of `numeric`, where each column is a time series. Accepts `list` and `data.frame` too. +#' @param window.size an `int` with the size of the sliding window. +#' @param exclusion.zone a `numeric`. Size of the exclusion zone, based on query size (default is `1/2`). +#' @param verbose an `int`. See details. (Default is `2`). +#' +#' @return Returns a list with the Matrix Profile `mp` and Profile Index `pi`. +#' +#' @export +#' @references 1. Silva D, Yeh C, Batista G, Keogh E. Simple: Assessing Music Similarity Using Subsequences Joins. Proc 17th ISMIR Conf. 2016;23–30. +#' @references 2. Silva DF, Yeh C-CM, Zhu Y, Batista G, Keogh E. Fast Similarity Matrix Profile for Music Analysis and Exploration. IEEE Trans Multimed. 2018;14(8):1–1. +#' @references Website: +#' @references Website: +#' +#' @examples +#' w <- 30 +#' data <- toy_data$data # 3 dimensions matrix +#' result <- simple.fast(data, w, verbose = 0) +#' +simple.fast <- function(data, window.size, exclusion.zone = 1 / 2, verbose = 2) { + ## get various length + exclusion.zone <- floor(window.size * exclusion.zone) + + ## transform data list into matrix + if (is.list(data)) { + data.size <- length(data[[1]]) + n.dim <- length(data) + + for (i in 1:n.dim) { + len <- length(data[[i]]) + # Fix TS size with NaN + if (len < data.size) { + data[[i]] <- c(data[[i]], rep(NA, data.size - len)) + } + } + # transform data into matrix (each column is a TS) + data <- sapply(data, cbind) + } else if (is.matrix(data) || is.data.frame(data)) { + if (is.data.frame(data)) { + data <- as.matrix(data) + } # just to be uniform + if (ncol(data) > nrow(data)) { + data <- t(data) + } + data.size <- nrow(data) + n.dim <- ncol(data) + } else if (is.vector(data)) { + data.size <- length(data) + n.dim <- 1 + # transform data into 1-col matrix + data <- as.matrix(data) # just to be uniform + } else { + stop("Unknown type of data. Must be: matrix, data.frame, vector or list") + } + + ## check input + if (window.size > data.size / 2) { + stop("Error: Time series is too short relative to desired subsequence length") + } + if (window.size < 4) { + stop("Error: Subsequence length must be at least 4") + } + + ## initialization + matrix.profile.size <- data.size - window.size + 1 + matrix.profile <- rep(Inf, matrix.profile.size) + profile.index <- rep(0, matrix.profile.size) + + if (verbose > 0) { + pb <- utils::txtProgressBar(min = 0, max = matrix.profile.size, style = 3, width = 80) + on.exit(close(pb)) + } + if (verbose > 1) { + on.exit(beep(sounds[[1]]), TRUE) + } + + ## compute necessary values + res <- mass.simple.pre(data, data.size, window.size = window.size) + data.fft <- res$data.fft + sumx2 <- res$sumx2 + + ## compute first distance profile + query.window <- data[1:window.size, ] + res <- mass.simple(data.fft, query.window, data.size, window.size, sumx2) + distance.profile <- res$distance.profile + first.product <- last.product <- res$last.product + sumy2 <- res$sumy2 + dropval <- query.window[1, ] + distance.profile[1:exclusion.zone] <- Inf + + + ind <- which.min(distance.profile) + profile.index[1] <- ind + matrix.profile[1] <- distance.profile[ind] + + ## compute the remainder of the matrix profile + for (i in 2:matrix.profile.size) { + + # compute the distance profile + if (verbose > 0) { + utils::setTxtProgressBar(pb, i) + } + + query.window <- data[i:(i + window.size - 1), ] + + sumy2 <- sumy2 - dropval^2 + query.window[window.size, ]^2 + + for (j in 1:n.dim) { + last.product[2:(data.size - window.size + 1), j] <- last.product[1:(data.size - window.size), j] - + data[1:(data.size - window.size), j] * dropval[j] + + data[(window.size + 1):data.size, j] * query.window[window.size, j] + } + + last.product[1, ] <- first.product[i, ] + dropval <- query.window[1, ] + + distance.profile <- matrix(0, nrow(sumx2), 1) + + for (j in 1:n.dim) { + distance.profile <- distance.profile + sumx2[, j] - 2 * last.product[, j] + sumy2[j] + } + + exc.st <- max(1, i - exclusion.zone) + exc.ed <- min(matrix.profile.size, i + exclusion.zone) + distance.profile[exc.st:exc.ed] <- Inf + + ind <- which.min(distance.profile) + profile.index[i] <- ind + matrix.profile[i] <- distance.profile[ind] + } + + return(list(mp = matrix.profile, pi = profile.index)) +} + +#' Precomputes several values used on MASS +#' +#' The difference of this function to [mass.pre()] is that this does not normalize data. Specific for this domain. +#' +#' @param data a `matrix` of `numeric`. Reference Time Series. +#' @param data.size an `int`. Reference Time Series size. +#' @param window.size an `int`. Sliding window size. +#' +#' @return Returns `data.fft` and `sumx2`. +#' @keywords internal +#' +#' @references Abdullah Mueen, Yan Zhu, Michael Yeh, Kaveh Kamgar, Krishnamurthy Viswanathan, Chetan Kumar Gupta and Eamonn Keogh (2015), The Fastest Similarity Search Algorithm for Time Series Subsequences under Euclidean Distance. +#' @references + + +mass.simple.pre <- function(data, data.size, window.size) { + if (nrow(data) < ncol(data)) { + data <- t(data) + } + + n.dim <- ncol(data) + + data <- rbind(data, matrix(0, data.size, n.dim)) + + data.fft <- apply(data, 2, stats::fft) + cum_sumx2 <- apply(data^2, 2, cumsum) + + sumx2 <- cum_sumx2[window.size:data.size, ] - rbind(rep(0, n.dim), cum_sumx2[1:(data.size - window.size), ]) + + return(list(data.fft = data.fft, sumx2 = sumx2)) +} + +#' Calculates the distance profile using MASS algorithm +#' +#' Mueen's Algorithm for Similarity Search is The Fastest Similarity Search Algorithm for Time Series Subsequences under Euclidean Distance and Correlation Coefficient. +#' The difference of this function to [mass()] is that this does not normalize data. Specific for this domain. +#' +#' @param data.fft precomputed data product. +#' @param query.window a `matrix` of `numeric`. Query window. +#' @param data.size an `int`. The length of the reference data. +#' @param window.size an `int`. Sliding window size. +#' @param sumx2 precomputed sum of squares +#' +#' @return Returns the `distance.profile` for the given query and the `last.product` for STOMP algorithm and `sumy2`. +#' @keywords internal +#' +#' @references Abdullah Mueen, Yan Zhu, Michael Yeh, Kaveh Kamgar, Krishnamurthy Viswanathan, Chetan Kumar Gupta and Eamonn Keogh (2015), The Fastest Similarity Search Algorithm for Time Series Subsequences under Euclidean Distance +#' @references +#' + + +mass.simple <- function(data.fft, query.window, data.size, window.size, sumx2) { + if (nrow(data.fft) < ncol(data.fft)) { + data.fft <- t(data.fft) + } + + n.dim <- ncol(data.fft) + + if (ncol(query.window) != n.dim) { + query.window <- t(query.window) + } + + # pre-process query for fft + query.window <- apply(query.window, 2, rev) + query.window <- rbind(query.window, matrix(0, 2 * data.size - window.size, n.dim)) + + query.fft <- apply(query.window, 2, stats::fft) + # compute the product + Z <- data.fft * query.fft + z <- apply(Z, 2, function(x){ + stats::fft(x, inverse = TRUE) / length(x) + }) + + sumy2 <- apply(query.window^2, 2, sum) + + last.product <- Re(z[window.size:data.size, ]) + + distance.profile <- matrix(0, nrow(sumx2), 1) + + for (i in 1:n.dim) { + distance.profile <- distance.profile + sumx2[, i] - 2 * last.product[, i] + sumy2[i] + } + + return(list(distance.profile = distance.profile, last.product = last.product, sumy2 = sumy2)) +} diff --git a/R/stamp.R b/R/stamp.R index 82e4571..542ddb6 100644 --- a/R/stamp.R +++ b/R/stamp.R @@ -10,7 +10,7 @@ #' @param ... a `matrix` or a `vector`. If a second time series is supplied it will be a join matrix profile. #' @param window.size an `int`. Size of the sliding window. #' @param exclusion.zone a `numeric`. Size of the exclusion zone, based on query size (default is `1/2`). See details. -#' @param s.size a `numeric`. for anytime algorithm, represents the size (in observations) the random calculation will occour (default is `Inf`). +#' @param s.size a `numeric`. for anytime algorithm, represents the size (in observations) the random calculation will occur (default is `Inf`). #' @param verbose an `int`. See details. (Default is `2`). #' #' @return Returns the matrix profile `mp` and profile index `pi`. @@ -98,7 +98,7 @@ stamp <- function(..., window.size, exclusion.zone = 1 / 2, s.size = Inf, verbos on.exit(close(pb)) } if (verbose > 1) { - on.exit(beepr::beep(), TRUE) + on.exit(beep(sounds[[1]]), TRUE) } # anytime must return the result always on.exit(return(list( diff --git a/R/stamp_par.R b/R/stamp_par.R index 9d94b66..40ba10d 100644 --- a/R/stamp_par.R +++ b/R/stamp_par.R @@ -10,7 +10,7 @@ #' @param ... a `matrix` or a `vector`. If a second time series is supplied it will be a join matrix profile. #' @param window.size an `int`. Size of the sliding window. #' @param exclusion.zone a `numeric`. Size of the exclusion zone, based on query size (default is `1/2`). See details. -#' @param s.size a `numeric`. for anytime algorithm, represents the size (in observations) the random calculation will occour (default is `Inf`). +#' @param s.size a `numeric`. for anytime algorithm, represents the size (in observations) the random calculation will occur (default is `Inf`). #' @param n.workers an `int`. Number of workers for parallel. (Default is `2`). #' @param verbose an `int`. See details. (Default is `2`). #' @@ -25,7 +25,6 @@ #' @references Website: #' #' @examples -#' Sys.sleep(1) # sometimes sleep is needed if you run parallel multiple times in a row #' mp <- stamp.par(toy_data$data[1:200,1], window.size = 30, verbose = 0) #' \dontrun{ #' ref.data <- toy_data$data[,1] @@ -36,7 +35,7 @@ #' mp <- stamp.par(ref.data, query.data, window.size = 30, s.size = round(nrows(query.data) * 0.1)) #' } #' -#' @import beepr doSNOW foreach parallel +#' @import doSNOW foreach parallel stamp.par <- function(..., window.size, exclusion.zone = 1 / 2, s.size = Inf, n.workers = 2, verbose = 2) { args <- list(...) data <- args[[1]] @@ -107,7 +106,7 @@ stamp.par <- function(..., window.size, exclusion.zone = 1 / 2, s.size = Inf, n. on.exit(close(pb), TRUE) } if (verbose > 1) { - on.exit(beepr::beep(), TRUE) + on.exit(beep(sounds[[1]]), TRUE) } # anytime must return the result always on.exit(return(list( diff --git a/R/sysdata.rda b/R/sysdata.rda new file mode 100644 index 0000000..e159947 Binary files /dev/null and b/R/sysdata.rda differ diff --git a/R/toy_data.R b/R/toy_data.R index 49007b5..2e383e3 100644 --- a/R/toy_data.R +++ b/R/toy_data.R @@ -1,11 +1,11 @@ #' Original data used in the mSTAMP demo #' -#' A synthetic dataset with embeded MOTIFs for multidimensional discovery +#' A synthetic dataset with embedded MOTIFs for multidimensional discovery #' #' @docType data #' @format A `list` with a `matrix` with 550 rows and 3 dimensions and an `int`: #' \describe{ -#' \item{data}{data with embeded MOTIFs} +#' \item{data}{data with embedded MOTIFs} #' \item{sub.len}{size of sliding window} #' } #' @source \url{https://sites.google.com/view/mstamp/} diff --git a/R/tsmp-package.R b/R/tsmp-package.R index 5dde173..320e0ed 100644 --- a/R/tsmp-package.R +++ b/R/tsmp-package.R @@ -1,4 +1,4 @@ -#' +#' @title Time Series with Matrix Profile #' @docType package #' @name tsmp #' @references diff --git a/README.Rmd b/README.Rmd index f2bcec2..f7846e0 100644 --- a/README.Rmd +++ b/README.Rmd @@ -15,12 +15,12 @@ knitr::opts_chunk$set( ) ``` -# Time Series Matrix-Profile +# Time Series with Matrix Profile ```{r include=FALSE} library(git2r) # current.branch <- repository_head()$name -current.branch <- "develop" +current.branch <- "master" lifecycle <- "maturing" # maturing-blue # stable-brightgreen lifecycle.color <- "blue" ``` @@ -76,14 +76,14 @@ devtools::install_github("franzbischoff/tsmp") * Time Series Chains * FLUSS Arc Plot and SiMPle Arc Plot * Annotation vectors (e.g.: Stop-word MOTIF bias, Actionability bias) -* SiMPle-Fast (Fast Similarity Matrix-Profile for Music Analysis and Exploration) +* SiMPle-Fast (Fast Similarity Matrix Profile for Music Analysis and Exploration) * MOTIFs under Uniform Scaling * GPU-STOMP * Real-time version of previous algorithms (STAMPI, FLOSS, etc) * MASS Extensions (ADP, WQ, QwG) * SCRIMP (waiting for publication) -## Other projects with Matrix-Profile +## Other projects with Matrix Profile - Python: https://github.com/ZiyaoWei/pyMatrixProfile ## Code of Conduct diff --git a/README.md b/README.md index f8aa9a3..9188b2b 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ README ================ Francisco Bischoff -\- 18 Aug 2018 +\- 20 Aug 2018 -# Time Series Matrix-Profile +# Time Series with Matrix Profile [![Packagist](https://img.shields.io/packagist/l/doctrine/orm.svg)](https://choosealicense.com/licenses/mit) [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) [![Build -Status](https://travis-ci.com/franzbischoff/tsmp.svg?branch=develop)](https://travis-ci.com/franzbischoff/tsmp) -[![codecov](https://codecov.io/gh/franzbischoff/tsmp/branch/develop/graph/badge.svg)](https://codecov.io/gh/franzbischoff/tsmp) +Status](https://travis-ci.com/franzbischoff/tsmp.svg?branch=master)](https://travis-ci.com/franzbischoff/tsmp) +[![codecov](https://codecov.io/gh/franzbischoff/tsmp/branch/master/graph/badge.svg)](https://codecov.io/gh/franzbischoff/tsmp) [![CRAN version](http://www.r-pkg.org/badges/version/tsmp)](https://cran.r-project.org/package=tsmp) @@ -60,7 +60,7 @@ devtools::install_github("franzbischoff/tsmp") - Time Series Chains - FLUSS Arc Plot and SiMPle Arc Plot - Annotation vectors (e.g.: Stop-word MOTIF bias, Actionability bias) - - SiMPle-Fast (Fast Similarity Matrix-Profile for Music Analysis and + - SiMPle-Fast (Fast Similarity Matrix Profile for Music Analysis and Exploration) - MOTIFs under Uniform Scaling - GPU-STOMP @@ -68,12 +68,12 @@ devtools::install_github("franzbischoff/tsmp") - MASS Extensions (ADP, WQ, QwG) - SCRIMP (waiting for publication) -## Other projects with Matrix-Profile +## Other projects with Matrix Profile - Python: ## Code of Conduct Please note that this project is released with a [Contributor Code of -Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to -abide by its terms. +Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree +to abide by its terms. diff --git a/cran-comments.md b/cran-comments.md index a1287a4..24d81b0 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,4 +1,5 @@ -This is a point release fixing failing tests on CRAN. +* Changed dependency from beepr to audio (actually beepr depends on audio, so less dependencies). +* Added persons to DESCRIPTION as their code/research was implemented in this package. ## Test environments * local Windows 10 install, R 3.5.1 diff --git a/data/datalist b/data/datalist index 818d7bb..5f4867d 100644 --- a/data/datalist +++ b/data/datalist @@ -1,3 +1,4 @@ test_data toy_data fluss_data +gait_data diff --git a/data/gait_data.rda b/data/gait_data.rda new file mode 100644 index 0000000..235d48c Binary files /dev/null and b/data/gait_data.rda differ diff --git a/docs/CODE_OF_CONDUCT.html b/docs/CODE_OF_CONDUCT.html new file mode 100644 index 0000000..37fa517 --- /dev/null +++ b/docs/CODE_OF_CONDUCT.html @@ -0,0 +1,178 @@ + + + + + + + + +Contributor Covenant Code of Conduct • tsmp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+ +
+
+ + +
+ +
+

+Our Pledge

+

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

+
+
+

+Our Standards

+

Examples of behavior that contributes to creating a positive environment include:

+
    +
  • Using welcoming and inclusive language
  • +
  • Being respectful of differing viewpoints and experiences
  • +
  • Gracefully accepting constructive criticism
  • +
  • Focusing on what is best for the community
  • +
  • Showing empathy towards other community members
  • +
+

Examples of unacceptable behavior by participants include:

+
    +
  • The use of sexualized language or imagery and unwelcome sexual attention or advances
  • +
  • Trolling, insulting/derogatory comments, and personal or political attacks
  • +
  • Public or private harassment
  • +
  • Publishing others’ private information, such as a physical or electronic address, without explicit permission
  • +
  • Other conduct which could reasonably be considered inappropriate in a professional setting
  • +
+
+
+

+Our Responsibilities

+

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

+

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

+
+
+

+Scope

+

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

+
+
+

+Enforcement

+

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

+

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project’s leadership.

+
+
+

+Attribution

+

This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4

+
+
+ +
+ +
+ + +
+ + +
+

Site built with pkgdown.

+
+ +
+
+ + + + + + diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index c54b96b..aeb627f 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -61,7 +61,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/LICENSE.html b/docs/LICENSE.html index 9f5ec63..88aefef 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -61,7 +61,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/authors.html b/docs/authors.html index 005f86e..59f6a2a 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -61,7 +61,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -109,7 +109,15 @@

Authors

  • -

    Michael Yeh. Researcher, conceptor, contributor. +

    Michael Yeh. Researcher, conceptor, contributor. +

    +
  • +
  • +

    Diego Silva. Researcher, conceptor, contributor. +

    +
  • +
  • +

    Yan Zhu. Researcher, conceptor, contributor.

  • diff --git a/docs/favicon.ico b/docs/favicon.ico new file mode 100644 index 0000000..10b994a Binary files /dev/null and b/docs/favicon.ico differ diff --git a/docs/index.html b/docs/index.html index 6581c08..db7aef0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -30,7 +30,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -72,9 +72,9 @@ -
    +
    @@ -123,7 +123,7 @@

  • Time Series Chains
  • FLUSS Arc Plot and SiMPle Arc Plot
  • Annotation vectors (e.g.: Stop-word MOTIF bias, Actionability bias)
  • -
  • SiMPle-Fast (Fast Similarity Matrix-Profile for Music Analysis and Exploration)
  • +
  • SiMPle-Fast (Fast Similarity Matrix Profile for Music Analysis and Exploration)
  • MOTIFs under Uniform Scaling
  • GPU-STOMP
  • Real-time version of previous algorithms (STAMPI, FLOSS, etc)
  • @@ -133,7 +133,7 @@

    -Other projects with Matrix-Profile

    +Other projects with Matrix Profile
    @@ -179,8 +179,9 @@

    Dev status

    • Packagist
    • lifecycle
    • -
    • Build Status
    • -
    • codecov
    • +
    • Build Status
    • +
    • codecov
    • +
    • CRAN version
    diff --git a/docs/news/index.html b/docs/news/index.html index fe4e80c..8d2c3a5 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -61,7 +61,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -104,11 +104,15 @@

    Changelog

    Source: NEWS.md -
    +

    -tsmp 0.2.30 Unreleased +tsmp 0.2.14 Unreleased

      +
    • Added SiMPle algorithm for sound data.
    • +
    • Added FLUSS algorithm.
    • +
    • Added [find.chains()] to look for chains primitives.
    • +
    • Changed dependency from beepr to audio (actually beepr depends on audio, so less dependencies)
    • Added a NEWS.md file to track changes to the package.
    @@ -137,7 +141,7 @@

    Contents

    diff --git a/docs/reference/beep.html b/docs/reference/beep.html new file mode 100644 index 0000000..1d0b7fc --- /dev/null +++ b/docs/reference/beep.html @@ -0,0 +1,154 @@ + + + + + + + + +Play sound with <code>audio</code> — beep • tsmp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Play sound with audio

    + +
    + +
    beep(data)
    + +

    Arguments

    + + + + + + +
    data

    sound data provided by this package

    + + +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + + + + diff --git a/docs/reference/compute.f.meas.html b/docs/reference/compute.f.meas.html index 92b88d4..0c93a1d 100644 --- a/docs/reference/compute.f.meas.html +++ b/docs/reference/compute.f.meas.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009
    diff --git a/docs/reference/fast.movavg.html b/docs/reference/fast.movavg.html index 118467b..dd8744a 100644 --- a/docs/reference/fast.movavg.html +++ b/docs/reference/fast.movavg.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009

    diff --git a/docs/reference/fast.movsd.html b/docs/reference/fast.movsd.html index 1674e73..b08683f 100644 --- a/docs/reference/fast.movsd.html +++ b/docs/reference/fast.movsd.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/reference/find.chains.html b/docs/reference/find.chains.html new file mode 100644 index 0000000..85d5ba9 --- /dev/null +++ b/docs/reference/find.chains.html @@ -0,0 +1,357 @@ + + + + + + + + +Find Time Series Chains — find.chains • tsmp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Time Series Chains is a new primitive for time series data mining.

    + +
    + +
    find.chains(matrices)
    + +

    Arguments

    + + + + + + +
    matrices

    a result from STAMP or STOMP algorithms

    + +

    Value

    + +

    Returns chains, a list of chains founded with more than 2 patterns and best +with the best one.

    + +

    References

    + +
      +
    1. Zhu Y, Imamura M, Nikovski D, Keogh E. Introducing time series chains: a new +primitive for time series data mining. Knowl Inf Syst. 2018 Jun 2;1–27.

    2. +
    +

    Website: https://sites.google.com/site/timeserieschain/

    + + +

    Examples

    +
    w <- 50 +data <- gait_data +mp <- stamp(data, window.size = w, exclusion.zone = 1/4, verbose = 0) +find.chains(mp)
    #> $chains +#> $chains[[1]] +#> [1] 1 145 377 +#> +#> $chains[[2]] +#> [1] 2 111 344 712 +#> +#> $chains[[3]] +#> [1] 3 112 345 713 +#> +#> $chains[[4]] +#> [1] 4 113 346 714 +#> +#> $chains[[5]] +#> [1] 5 114 347 715 +#> +#> $chains[[6]] +#> [1] 6 115 348 716 +#> +#> $chains[[7]] +#> [1] 30 67 168 668 +#> +#> $chains[[8]] +#> [1] 31 68 169 669 +#> +#> $chains[[9]] +#> [1] 102 335 703 +#> +#> $chains[[10]] +#> [1] 103 336 704 +#> +#> $chains[[11]] +#> [1] 104 337 705 +#> +#> $chains[[12]] +#> [1] 105 338 706 +#> +#> $chains[[13]] +#> [1] 106 339 707 +#> +#> $chains[[14]] +#> [1] 107 340 708 +#> +#> $chains[[15]] +#> [1] 108 341 709 +#> +#> $chains[[16]] +#> [1] 109 342 710 +#> +#> $chains[[17]] +#> [1] 110 343 711 +#> +#> $chains[[18]] +#> [1] 117 349 717 +#> +#> $chains[[19]] +#> [1] 148 380 614 746 778 811 +#> +#> $chains[[20]] +#> [1] 192 491 592 +#> +#> $chains[[21]] +#> [1] 193 492 593 +#> +#> $chains[[22]] +#> [1] 194 493 594 +#> +#> $chains[[23]] +#> [1] 195 494 595 +#> +#> $chains[[24]] +#> [1] 196 495 596 +#> +#> $chains[[25]] +#> [1] 197 496 597 +#> +#> $chains[[26]] +#> [1] 198 497 598 +#> +#> $chains[[27]] +#> [1] 199 498 599 +#> +#> $chains[[28]] +#> [1] 200 499 600 +#> +#> $chains[[29]] +#> [1] 201 500 601 +#> +#> $chains[[30]] +#> [1] 202 501 602 +#> +#> $chains[[31]] +#> [1] 215 248 615 747 779 812 +#> +#> $chains[[32]] +#> [1] 216 282 314 +#> +#> $chains[[33]] +#> [1] 217 283 315 +#> +#> $chains[[34]] +#> [1] 218 284 316 +#> +#> $chains[[35]] +#> [1] 219 285 317 +#> +#> $chains[[36]] +#> [1] 220 253 719 +#> +#> $chains[[37]] +#> [1] 221 254 720 +#> +#> $chains[[38]] +#> [1] 227 260 560 +#> +#> $chains[[39]] +#> [1] 228 261 561 +#> +#> $chains[[40]] +#> [1] 229 262 562 +#> +#> $chains[[41]] +#> [1] 230 263 563 +#> +#> $chains[[42]] +#> [1] 231 264 564 +#> +#> $chains[[43]] +#> [1] 232 265 565 +#> +#> $chains[[44]] +#> [1] 233 266 566 +#> +#> $chains[[45]] +#> [1] 234 267 567 +#> +#> $chains[[46]] +#> [1] 235 333 701 +#> +#> $chains[[47]] +#> [1] 249 616 748 +#> +#> $chains[[48]] +#> [1] 250 617 749 +#> +#> $chains[[49]] +#> [1] 443 775 808 +#> +#> $chains[[50]] +#> [1] 444 776 809 +#> +#> $chains[[51]] +#> [1] 445 777 810 +#> +#> $chains[[52]] +#> [1] 552 685 849 +#> +#> $chains[[53]] +#> [1] 553 686 850 +#> +#> $chains[[54]] +#> [1] 554 687 851 +#> +#> $chains[[55]] +#> [1] 555 688 852 +#> +#> $chains[[56]] +#> [1] 556 689 853 +#> +#> $chains[[57]] +#> [1] 557 690 854 +#> +#> $chains[[58]] +#> [1] 558 691 855 +#> +#> +#> $best +#> [1] 148 380 614 746 778 811 +#>
    +
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + + + + diff --git a/docs/reference/fluss.cac.html b/docs/reference/fluss.cac.html index 6f70057..bc3de70 100644 --- a/docs/reference/fluss.cac.html +++ b/docs/reference/fluss.cac.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -140,7 +140,7 @@

    Value

    Details

    Original paper suggest using the classic statistical-process-control heuristic to set a threshold -where a semantic change may occur in CAC. This may be useful in realtime implementation as we don't +where a semantic change may occur in CAC. This may be useful in real-time implementation as we don't know in advance the number of domain changes to look for. Please check original paper (1).

    References

    diff --git a/docs/reference/fluss.extract.html b/docs/reference/fluss.extract.html index be4511c..d2f8be1 100644 --- a/docs/reference/fluss.extract.html +++ b/docs/reference/fluss.extract.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/reference/fluss.html b/docs/reference/fluss.html index c49815d..81456de 100644 --- a/docs/reference/fluss.html +++ b/docs/reference/fluss.html @@ -64,7 +64,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/reference/fluss.score.html b/docs/reference/fluss.score.html index e17aa67..9fa66e3 100644 --- a/docs/reference/fluss.score.html +++ b/docs/reference/fluss.score.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/reference/fluss_data.html b/docs/reference/fluss_data.html index 40cab54..061a2e5 100644 --- a/docs/reference/fluss_data.html +++ b/docs/reference/fluss_data.html @@ -64,7 +64,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/reference/gait_data.html b/docs/reference/gait_data.html new file mode 100644 index 0000000..1026321 --- /dev/null +++ b/docs/reference/gait_data.html @@ -0,0 +1,164 @@ + + + + + + + + +Original data used in the Time Series Chain demo — gait_data • tsmp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Original data used in the Time Series Chain demo

    + +
    + +
    gait_data
    + +

    Format

    + +

    A matrix with 904 rows and 1 column with the Y data from an accelerometer

    + +

    Source

    + +

    https://sites.google.com/site/timeserieschain/

    + +

    References

    + +
      +
    1. Zhu Y, Imamura M, Nikovski D, Keogh E. Introducing time series chains: a new primitive for time series data mining. Knowl Inf Syst. 2018 Jun 2;1–27.

    2. +
    + + +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + + + + diff --git a/docs/reference/golden.section.2.html b/docs/reference/golden.section.2.html index a6de8cb..aeaff7e 100644 --- a/docs/reference/golden.section.2.html +++ b/docs/reference/golden.section.2.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -155,7 +155,7 @@

    Arg

    Value

    -

    Returns the best threashold and its F-Score

    +

    Returns the best threshold and its F-Score

    diff --git a/docs/reference/golden.section.html b/docs/reference/golden.section.html index e75dff6..bf91a6f 100644 --- a/docs/reference/golden.section.html +++ b/docs/reference/golden.section.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -146,7 +146,7 @@

    Arg

    Value

    -

    Returns the best threashold and its F-Score

    +

    Returns the best threshold and its F-Score

    diff --git a/docs/reference/guide.search.html b/docs/reference/guide.search.html index f440828..ee2ee2b 100644 --- a/docs/reference/guide.search.html +++ b/docs/reference/guide.search.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -120,7 +120,7 @@

    Arg data -

    a matrix of numeric, where each colums is a time series. Accepts vector (see details), list and data.frame too.

    +

    a matrix of numeric, where each column is a time series. Accepts vector (see details), list and data.frame too.

    window.size diff --git a/docs/reference/index.html b/docs/reference/index.html index 5f60717..be26baf 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -61,7 +61,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -132,6 +132,12 @@

    find.chains()

    + +

    Find Time Series Chains

    + +

    fluss.cac()

    @@ -162,6 +168,12 @@

    gait_data

    + +

    Original data used in the Time Series Chain demo

    + +

    guide.search()

    @@ -210,6 +222,12 @@

    simple.fast()

    + +

    Compute the similarity join for Sound data.

    + +

    stamp.par()

    @@ -237,7 +255,7 @@

    tsmp

    -

    Package development tools for R.

    +

    Time Series with Matrix Profile

    diff --git a/docs/reference/mass.html b/docs/reference/mass.html index 1c7f53b..794c65c 100644 --- a/docs/reference/mass.html +++ b/docs/reference/mass.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/reference/mass.pre.html b/docs/reference/mass.pre.html index 453f4bc..3b83f87 100644 --- a/docs/reference/mass.pre.html +++ b/docs/reference/mass.pre.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/reference/mass.simple.html b/docs/reference/mass.simple.html new file mode 100644 index 0000000..a8825af --- /dev/null +++ b/docs/reference/mass.simple.html @@ -0,0 +1,185 @@ + + + + + + + + +Calculates the distance profile using MASS algorithm — mass.simple • tsmp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Mueen's Algorithm for Similarity Search is The Fastest Similarity Search Algorithm for Time Series Subsequences under Euclidean Distance and Correlation Coefficient. +The difference of this function to mass() is that this does not normalize data. Specific for this domain.

    + +
    + +
    mass.simple(data.fft, query.window, data.size, window.size, sumx2)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    data.fft

    precomputed data product.

    query.window

    a matrix of numeric. Query window.

    data.size

    an int. The length of the reference data.

    window.size

    an int. Sliding window size.

    sumx2

    precomputed sum of squares

    + +

    Value

    + +

    Returns the distance.profile for the given query and the last.product for STOMP algorithm and sumy2.

    + +

    References

    + +

    Abdullah Mueen, Yan Zhu, Michael Yeh, Kaveh Kamgar, Krishnamurthy Viswanathan, Chetan Kumar Gupta and Eamonn Keogh (2015), The Fastest Similarity Search Algorithm for Time Series Subsequences under Euclidean Distance

    +

    https://www.cs.unm.edu/~mueen/FastestSimilaritySearch.html

    + + +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + + + + diff --git a/docs/reference/mass.simple.pre.html b/docs/reference/mass.simple.pre.html new file mode 100644 index 0000000..db1ce95 --- /dev/null +++ b/docs/reference/mass.simple.pre.html @@ -0,0 +1,175 @@ + + + + + + + + +Precomputes several values used on MASS — mass.simple.pre • tsmp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    The difference of this function to mass.pre() is that this does not normalize data. Specific for this domain.

    + +
    + +
    mass.simple.pre(data, data.size, window.size)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    data

    a matrix of numeric. Reference Time Series.

    data.size

    an int. Reference Time Series size.

    window.size

    an int. Sliding window size.

    + +

    Value

    + +

    Returns data.fft and sumx2.

    + +

    References

    + +

    Abdullah Mueen, Yan Zhu, Michael Yeh, Kaveh Kamgar, Krishnamurthy Viswanathan, Chetan Kumar Gupta and Eamonn Keogh (2015), The Fastest Similarity Search Algorithm for Time Series Subsequences under Euclidean Distance.

    +

    https://www.cs.unm.edu/~mueen/FastestSimilaritySearch.html

    + + +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + + + + diff --git a/docs/reference/mode.html b/docs/reference/mode.html index 1224df2..1e3953e 100644 --- a/docs/reference/mode.html +++ b/docs/reference/mode.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/reference/mstomp.html b/docs/reference/mstomp.html index e13dd24..88ba273 100644 --- a/docs/reference/mstomp.html +++ b/docs/reference/mstomp.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -121,7 +121,7 @@

    Arg data -

    a matrix of numeric, where each colums is a time series. Accepts vector (see details), list and data.frame too.

    +

    a matrix of numeric, where each column is a time series. Accepts vector (see details), list and data.frame too.

    window.size diff --git a/docs/reference/mstomp.par.html b/docs/reference/mstomp.par.html index 2fc40aa..ca0714c 100644 --- a/docs/reference/mstomp.par.html +++ b/docs/reference/mstomp.par.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -121,7 +121,7 @@

    Arg data -

    a matrix of numeric, where each colums is a time series. Accepts vector (see details), list and data.frame too.

    +

    a matrix of numeric, where each column is a time series. Accepts vector (see details), list and data.frame too.

    window.size @@ -181,7 +181,6 @@

    See a

    Examples

    # using all dimensions -Sys.sleep(1) # sometimes sleep is needed if you run parallel multiple times in a row mp <- mstomp.par(toy_data$data[1:100,], 30, verbose = 0)
    @@ -124,7 +124,7 @@

    Arg pred -

    a vector of logical. Predictied annotation from sdts.predict()

    +

    a vector of logical. Predicted annotation from sdts.predict()

    beta diff --git a/docs/reference/sdts.predict.html b/docs/reference/sdts.predict.html index 244a42d..3be888c 100644 --- a/docs/reference/sdts.predict.html +++ b/docs/reference/sdts.predict.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/reference/sdts.train.html b/docs/reference/sdts.train.html index 4a2097c..62f9daf 100644 --- a/docs/reference/sdts.train.html +++ b/docs/reference/sdts.train.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/reference/simple.fast.html b/docs/reference/simple.fast.html new file mode 100644 index 0000000..dabafd3 --- /dev/null +++ b/docs/reference/simple.fast.html @@ -0,0 +1,197 @@ + + + + + + + + +Compute the similarity join for Sound data. — simple.fast • tsmp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Compute the similarity join for Sound data.

    + +
    + +
    simple.fast(data, window.size, exclusion.zone = 1/2, verbose = 2)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    data

    a matrix of numeric, where each column is a time series. Accepts list and data.frame too.

    window.size

    an int with the size of the sliding window.

    exclusion.zone

    a numeric. Size of the exclusion zone, based on query size (default is 1/2).

    verbose

    an int. See details. (Default is 2).

    + +

    Value

    + +

    Returns a list with the Matrix Profile mp and Profile Index pi.

    + +

    Details

    + +

    verbose changes how much information is printed by this function; 0 means nothing, 1 means text, 2 means text and sound.

    + +

    References

    + +
      +
    1. Silva D, Yeh C, Batista G, Keogh E. Simple: Assessing Music Similarity Using Subsequences Joins. Proc 17th ISMIR Conf. 2016;23–30.

    2. +
    +
      +
    1. Silva DF, Yeh C-CM, Zhu Y, Batista G, Keogh E. Fast Similarity Matrix Profile for Music Analysis and Exploration. IEEE Trans Multimed. 2018;14(8):1–1.

    2. +
    +

    Website: https://sites.google.com/view/simple-fast

    +

    Website: https://sites.google.com/site/ismir2016simple/home

    + + +

    Examples

    +
    w <- 30 +data <- toy_data$data # 3 dimensions matrix +result <- simple.fast(data, w, verbose = 0)
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + + + + diff --git a/docs/reference/stamp.html b/docs/reference/stamp.html index 80f04fa..4804304 100644 --- a/docs/reference/stamp.html +++ b/docs/reference/stamp.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -133,7 +133,7 @@

    Arg s.size -

    a numeric. for anytime algorithm, represents the size (in observations) the random calculation will occour (default is Inf).

    +

    a numeric. for anytime algorithm, represents the size (in observations) the random calculation will occur (default is Inf).

    verbose diff --git a/docs/reference/stamp.par.html b/docs/reference/stamp.par.html index 27b219f..d6bf058 100644 --- a/docs/reference/stamp.par.html +++ b/docs/reference/stamp.par.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -133,7 +133,7 @@

    Arg s.size -

    a numeric. for anytime algorithm, represents the size (in observations) the random calculation will occour (default is Inf).

    +

    a numeric. for anytime algorithm, represents the size (in observations) the random calculation will occur (default is Inf).

    n.workers @@ -174,8 +174,7 @@

    See a

    Examples

    -
    Sys.sleep(1) # sometimes sleep is needed if you run parallel multiple times in a row -mp <- stamp.par(toy_data$data[1:200,1], window.size = 30, verbose = 0)
    # NOT RUN { +
    mp <- stamp.par(toy_data$data[1:200,1], window.size = 30, verbose = 0)
    # NOT RUN { ref.data <- toy_data$data[,1] query.data <- toy_data$data[,2] # self similarity diff --git a/docs/reference/std.html b/docs/reference/std.html index 504caef..4ad6ed7 100644 --- a/docs/reference/std.html +++ b/docs/reference/std.html @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/reference/test_data.html b/docs/reference/test_data.html index e45ab6e..e74569f 100644 --- a/docs/reference/test_data.html +++ b/docs/reference/test_data.html @@ -65,7 +65,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 diff --git a/docs/reference/toy_data.html b/docs/reference/toy_data.html index fc38ef7..55052f0 100644 --- a/docs/reference/toy_data.html +++ b/docs/reference/toy_data.html @@ -32,7 +32,7 @@ - + @@ -63,7 +63,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -109,7 +109,7 @@

    Original data used in the mSTAMP demo

    -

    A synthetic dataset with embeded MOTIFs for multidimensional discovery

    +

    A synthetic dataset with embedded MOTIFs for multidimensional discovery

    @@ -118,7 +118,7 @@

    Original data used in the mSTAMP demo

    Format

    A list with a matrix with 550 rows and 3 dimensions and an int:

    -
    data

    data with embeded MOTIFs

    +
    data

    data with embedded MOTIFs

    sub.len

    size of sliding window

    diff --git a/docs/reference/tsmp.html b/docs/reference/tsmp.html index 3280b07..4150bfa 100644 --- a/docs/reference/tsmp.html +++ b/docs/reference/tsmp.html @@ -6,7 +6,7 @@ -Package development tools for R. — tsmp • tsmp +Time Series with Matrix Profile — tsmp • tsmp @@ -30,7 +30,7 @@ - + @@ -64,7 +64,7 @@ tsmp - 0.2.13.9004 + 0.2.14.9009 @@ -103,7 +103,7 @@
    @@ -116,28 +116,6 @@

    Package development tools for R.

    -

    Package options

    - - -

    Devtools uses the following options to configure behaviour:

    -
      -
    • devtools.path: path to use for dev_mode

    • -
    • devtools.name: your name, used when signing draft -emails.

    • -
    • devtools.install.args: a string giving extra arguments passed -to R CMD install by install.

    • -
    • devtools.desc.author: a string providing a default Authors@R -string to be used in new DESCRIPTIONs. Should be a R code, and -look like "Hadley Wickham <h.wickham@gmail.com> [aut, cre]". See -as.person for more details.

    • -
    • devtools.desc.license: a default license string to use for -new packages.

    • -
    • devtools.desc.suggests: a character vector listing packages to -to add to suggests by defaults for new packages.

    • -
    • devtools.desc: a named list listing any other -extra options to add to DESCRIPTION

    • -
    -

    References

    http://www.cs.ucr.edu/~eamonn/MatrixProfile.html

    @@ -155,8 +133,6 @@

    See a

    Contents

    @@ -121,7 +121,7 @@

    Arg data -

    a matrix of numeric, where each colums is a time series. Accepts vector (see details), list and data.frame too.

    +

    a matrix of numeric, where each column is a time series. Accepts vector (see details), list and data.frame too.

    window.size diff --git a/man/beep.Rd b/man/beep.Rd new file mode 100644 index 0000000..ab21044 --- /dev/null +++ b/man/beep.Rd @@ -0,0 +1,15 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/misc.R +\name{beep} +\alias{beep} +\title{Play sound with \code{audio}} +\usage{ +beep(data) +} +\arguments{ +\item{data}{sound data provided by this package} +} +\description{ +Play sound with \code{audio} +} +\keyword{internal} diff --git a/man/find.chains.Rd b/man/find.chains.Rd new file mode 100644 index 0000000..c0d5ee4 --- /dev/null +++ b/man/find.chains.Rd @@ -0,0 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/find_chains.R +\name{find.chains} +\alias{find.chains} +\title{Find Time Series Chains} +\usage{ +find.chains(matrices) +} +\arguments{ +\item{matrices}{a result from STAMP or STOMP algorithms} +} +\value{ +Returns \code{chains}, a \code{list} of chains founded with more than 2 patterns and \code{best} +with the best one. +} +\description{ +Time Series Chains is a new primitive for time series data mining. +} +\examples{ +w <- 50 +data <- gait_data +mp <- stamp(data, window.size = w, exclusion.zone = 1/4, verbose = 0) +find.chains(mp) + +} +\references{ +\enumerate{ +\item Zhu Y, Imamura M, Nikovski D, Keogh E. Introducing time series chains: a new +primitive for time series data mining. Knowl Inf Syst. 2018 Jun 2;1–27. +} + +Website: \url{https://sites.google.com/site/timeserieschain/} +} diff --git a/man/fluss.cac.Rd b/man/fluss.cac.Rd index 46d0db1..33e2e83 100644 --- a/man/fluss.cac.Rd +++ b/man/fluss.cac.Rd @@ -22,7 +22,7 @@ Computes the arc count with edge correction (CAC). } \details{ Original paper suggest using the classic statistical-process-control heuristic to set a threshold -where a semantic change may occur in CAC. This may be useful in realtime implementation as we don't +where a semantic change may occur in CAC. This may be useful in real-time implementation as we don't know in advance the number of domain changes to look for. Please check original paper (1). } \examples{ @@ -32,6 +32,7 @@ data <- fluss_data$tilt.abp$data[1:1000] w <- 210 mp <- mstomp(data, w, verbose = 0) cac <- fluss.cac(mp$pi, w) + \dontrun{ data <- fluss_data$walkjogrun$data w <- fluss_data$walkjogrun$window # 80 diff --git a/man/gait_data.Rd b/man/gait_data.Rd new file mode 100644 index 0000000..bbf6c59 --- /dev/null +++ b/man/gait_data.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/gait_data.R +\docType{data} +\name{gait_data} +\alias{gait_data} +\title{Original data used in the Time Series Chain demo} +\format{A \code{matrix} with 904 rows and 1 column with the Y data from an accelerometer} +\source{ +\url{https://sites.google.com/site/timeserieschain/} +} +\usage{ +gait_data +} +\description{ +Original data used in the Time Series Chain demo +} +\references{ +\enumerate{ +\item Zhu Y, Imamura M, Nikovski D, Keogh E. Introducing time series chains: a new primitive for time series data mining. Knowl Inf Syst. 2018 Jun 2;1–27. +} +} +\keyword{datasets} diff --git a/man/golden.section.2.Rd b/man/golden.section.2.Rd index ce1d5e2..c28f66f 100644 --- a/man/golden.section.2.Rd +++ b/man/golden.section.2.Rd @@ -25,7 +25,7 @@ golden.section.2(dist.pro, thold, label, pos.st, pos.ed, beta, window.size, \item{fit.idx}{an integer with the index of the current threshold} } \value{ -Returns the best threashold and its F-Score +Returns the best threshold and its F-Score } \description{ Computes the golden section for combined candidates diff --git a/man/golden.section.Rd b/man/golden.section.Rd index 20bbeb3..5eefa74 100644 --- a/man/golden.section.Rd +++ b/man/golden.section.Rd @@ -20,7 +20,7 @@ golden.section(dist.pro, label, pos.st, pos.ed, beta, window.size) \item{window.size}{an integer with the sliding window size} } \value{ -Returns the best threashold and its F-Score +Returns the best threshold and its F-Score } \description{ Computes the golden section for individual candidates diff --git a/man/guide.search.Rd b/man/guide.search.Rd index f33d6ad..1fe64df 100644 --- a/man/guide.search.Rd +++ b/man/guide.search.Rd @@ -7,7 +7,7 @@ guide.search(data, window.size, matrix.profile, profile.index, n.dim) } \arguments{ -\item{data}{a \code{matrix} of \code{numeric}, where each colums is a time series. Accepts \code{vector} (see details), \code{list} and \code{data.frame} too.} +\item{data}{a \code{matrix} of \code{numeric}, where each column is a time series. Accepts \code{vector} (see details), \code{list} and \code{data.frame} too.} \item{window.size}{an \code{int} with the size of the sliding window.} diff --git a/man/mass.simple.Rd b/man/mass.simple.Rd new file mode 100644 index 0000000..13c08aa --- /dev/null +++ b/man/mass.simple.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/simple.R +\name{mass.simple} +\alias{mass.simple} +\title{Calculates the distance profile using MASS algorithm} +\usage{ +mass.simple(data.fft, query.window, data.size, window.size, sumx2) +} +\arguments{ +\item{data.fft}{precomputed data product.} + +\item{query.window}{a \code{matrix} of \code{numeric}. Query window.} + +\item{data.size}{an \code{int}. The length of the reference data.} + +\item{window.size}{an \code{int}. Sliding window size.} + +\item{sumx2}{precomputed sum of squares} +} +\value{ +Returns the \code{distance.profile} for the given query and the \code{last.product} for STOMP algorithm and \code{sumy2}. +} +\description{ +Mueen's Algorithm for Similarity Search is The Fastest Similarity Search Algorithm for Time Series Subsequences under Euclidean Distance and Correlation Coefficient. +The difference of this function to \code{\link[=mass]{mass()}} is that this does not normalize data. Specific for this domain. +} +\references{ +Abdullah Mueen, Yan Zhu, Michael Yeh, Kaveh Kamgar, Krishnamurthy Viswanathan, Chetan Kumar Gupta and Eamonn Keogh (2015), The Fastest Similarity Search Algorithm for Time Series Subsequences under Euclidean Distance + +\url{https://www.cs.unm.edu/~mueen/FastestSimilaritySearch.html} +} +\keyword{internal} diff --git a/man/mass.simple.pre.Rd b/man/mass.simple.pre.Rd new file mode 100644 index 0000000..bc62f2a --- /dev/null +++ b/man/mass.simple.pre.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/simple.R +\name{mass.simple.pre} +\alias{mass.simple.pre} +\title{Precomputes several values used on MASS} +\usage{ +mass.simple.pre(data, data.size, window.size) +} +\arguments{ +\item{data}{a \code{matrix} of \code{numeric}. Reference Time Series.} + +\item{data.size}{an \code{int}. Reference Time Series size.} + +\item{window.size}{an \code{int}. Sliding window size.} +} +\value{ +Returns \code{data.fft} and \code{sumx2}. +} +\description{ +The difference of this function to \code{\link[=mass.pre]{mass.pre()}} is that this does not normalize data. Specific for this domain. +} +\references{ +Abdullah Mueen, Yan Zhu, Michael Yeh, Kaveh Kamgar, Krishnamurthy Viswanathan, Chetan Kumar Gupta and Eamonn Keogh (2015), The Fastest Similarity Search Algorithm for Time Series Subsequences under Euclidean Distance. + +\url{https://www.cs.unm.edu/~mueen/FastestSimilaritySearch.html} +} +\keyword{internal} diff --git a/man/mstomp.Rd b/man/mstomp.Rd index 90fcf6b..880d584 100644 --- a/man/mstomp.Rd +++ b/man/mstomp.Rd @@ -8,7 +8,7 @@ mstomp(data, window.size, must.dim = NULL, exc.dim = NULL, exclusion.zone = 1/2, verbose = 2) } \arguments{ -\item{data}{a \code{matrix} of \code{numeric}, where each colums is a time series. Accepts \code{vector} (see details), \code{list} and \code{data.frame} too.} +\item{data}{a \code{matrix} of \code{numeric}, where each column is a time series. Accepts \code{vector} (see details), \code{list} and \code{data.frame} too.} \item{window.size}{an \code{int} with the size of the sliding window.} diff --git a/man/mstomp.par.Rd b/man/mstomp.par.Rd index e5150fa..169a9b0 100644 --- a/man/mstomp.par.Rd +++ b/man/mstomp.par.Rd @@ -8,7 +8,7 @@ mstomp.par(data, window.size, must.dim = NULL, exc.dim = NULL, exclusion.zone = 1/2, verbose = 2, n.workers = 2) } \arguments{ -\item{data}{a \code{matrix} of \code{numeric}, where each colums is a time series. Accepts \code{vector} (see details), \code{list} and \code{data.frame} too.} +\item{data}{a \code{matrix} of \code{numeric}, where each column is a time series. Accepts \code{vector} (see details), \code{list} and \code{data.frame} too.} \item{window.size}{an \code{int}. Size of the sliding window.} @@ -38,7 +38,6 @@ Although this functions handles Multivariate Time Series, it can also be used to } \examples{ # using all dimensions -Sys.sleep(1) # sometimes sleep is needed if you run parallel multiple times in a row mp <- mstomp.par(toy_data$data[1:100,], 30, verbose = 0) } \references{ diff --git a/man/sdts.f.score.Rd b/man/sdts.f.score.Rd index bef8d17..f62ac1a 100644 --- a/man/sdts.f.score.Rd +++ b/man/sdts.f.score.Rd @@ -9,7 +9,7 @@ sdts.f.score(gtruth, pred, beta = 1) \arguments{ \item{gtruth}{a \code{vector} of \code{logical}. Ground truth annotation.} -\item{pred}{a \code{vector} of \code{logical}. Predictied annotation from \code{\link[=sdts.predict]{sdts.predict()}}} +\item{pred}{a \code{vector} of \code{logical}. Predicted annotation from \code{\link[=sdts.predict]{sdts.predict()}}} \item{beta}{a \code{numeric}. See details. (default is \code{1}).} } diff --git a/man/simple.fast.Rd b/man/simple.fast.Rd new file mode 100644 index 0000000..2de9521 --- /dev/null +++ b/man/simple.fast.Rd @@ -0,0 +1,45 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/simple.R +\name{simple.fast} +\alias{simple.fast} +\title{Compute the similarity join for Sound data.} +\usage{ +simple.fast(data, window.size, exclusion.zone = 1/2, verbose = 2) +} +\arguments{ +\item{data}{a \code{matrix} of \code{numeric}, where each column is a time series. Accepts \code{list} and \code{data.frame} too.} + +\item{window.size}{an \code{int} with the size of the sliding window.} + +\item{exclusion.zone}{a \code{numeric}. Size of the exclusion zone, based on query size (default is \code{1/2}).} + +\item{verbose}{an \code{int}. See details. (Default is \code{2}).} +} +\value{ +Returns a list with the Matrix Profile \code{mp} and Profile Index \code{pi}. +} +\description{ +Compute the similarity join for Sound data. +} +\details{ +\code{verbose} changes how much information is printed by this function; \code{0} means nothing, \code{1} means text, \code{2} means text and sound. +} +\examples{ +w <- 30 +data <- toy_data$data # 3 dimensions matrix +result <- simple.fast(data, w, verbose = 0) + +} +\references{ +\enumerate{ +\item Silva D, Yeh C, Batista G, Keogh E. Simple: Assessing Music Similarity Using Subsequences Joins. Proc 17th ISMIR Conf. 2016;23–30. +} + +\enumerate{ +\item Silva DF, Yeh C-CM, Zhu Y, Batista G, Keogh E. Fast Similarity Matrix Profile for Music Analysis and Exploration. IEEE Trans Multimed. 2018;14(8):1–1. +} + +Website: \url{https://sites.google.com/view/simple-fast} + +Website: \url{https://sites.google.com/site/ismir2016simple/home} +} diff --git a/man/stamp.Rd b/man/stamp.Rd index 6ca3b81..c4cc4ab 100644 --- a/man/stamp.Rd +++ b/man/stamp.Rd @@ -14,7 +14,7 @@ stamp(..., window.size, exclusion.zone = 1/2, s.size = Inf, \item{exclusion.zone}{a \code{numeric}. Size of the exclusion zone, based on query size (default is \code{1/2}). See details.} -\item{s.size}{a \code{numeric}. for anytime algorithm, represents the size (in observations) the random calculation will occour (default is \code{Inf}).} +\item{s.size}{a \code{numeric}. for anytime algorithm, represents the size (in observations) the random calculation will occur (default is \code{Inf}).} \item{verbose}{an \code{int}. See details. (Default is \code{2}).} } diff --git a/man/stamp.par.Rd b/man/stamp.par.Rd index ba013ec..ca2850c 100644 --- a/man/stamp.par.Rd +++ b/man/stamp.par.Rd @@ -14,7 +14,7 @@ stamp.par(..., window.size, exclusion.zone = 1/2, s.size = Inf, \item{exclusion.zone}{a \code{numeric}. Size of the exclusion zone, based on query size (default is \code{1/2}). See details.} -\item{s.size}{a \code{numeric}. for anytime algorithm, represents the size (in observations) the random calculation will occour (default is \code{Inf}).} +\item{s.size}{a \code{numeric}. for anytime algorithm, represents the size (in observations) the random calculation will occur (default is \code{Inf}).} \item{n.workers}{an \code{int}. Number of workers for parallel. (Default is \code{2}).} @@ -34,7 +34,6 @@ The anytime STAMP computes the Matrix Profile and Profile Index in such manner t \code{exclusion.zone} is used to avoid trivial matches; if a query data is provided (join similarity), this parameter is ignored. } \examples{ -Sys.sleep(1) # sometimes sleep is needed if you run parallel multiple times in a row mp <- stamp.par(toy_data$data[1:200,1], window.size = 30, verbose = 0) \dontrun{ ref.data <- toy_data$data[,1] diff --git a/man/toy_data.Rd b/man/toy_data.Rd index 859bb62..698a35f 100644 --- a/man/toy_data.Rd +++ b/man/toy_data.Rd @@ -6,7 +6,7 @@ \title{Original data used in the mSTAMP demo} \format{A \code{list} with a \code{matrix} with 550 rows and 3 dimensions and an \code{int}: \describe{ -\item{data}{data with embeded MOTIFs} +\item{data}{data with embedded MOTIFs} \item{sub.len}{size of sliding window} }} \source{ @@ -16,7 +16,7 @@ toy_data } \description{ -A synthetic dataset with embeded MOTIFs for multidimensional discovery +A synthetic dataset with embedded MOTIFs for multidimensional discovery } \references{ \enumerate{ diff --git a/man/tsmp.Rd b/man/tsmp.Rd index aed565d..2e70aca 100644 --- a/man/tsmp.Rd +++ b/man/tsmp.Rd @@ -4,7 +4,7 @@ \name{tsmp} \alias{tsmp} \alias{tsmp-package} -\title{tsmp: Time Series with Matrix Profile} +\title{Time Series with Matrix Profile} \description{ \if{html}{\figure{logo.png}{options: align='right'}} @@ -26,7 +26,9 @@ Useful links: Other contributors: \itemize{ - \item Michael Yeh \email{myeh003@ucr.edu} [researcher, conceptor, contributor] + \item Michael Yeh \email{myeh003@ucr.edu} (https://orcid.org/0000-0002-9807-2963) [researcher, conceptor, contributor] + \item Diego Silva \email{diegofs@ufscar.br} (https://orcid.org/0000-0002-5184-9413) [researcher, conceptor, contributor] + \item Yan Zhu \email{yzhu015@ucr.edu} [researcher, conceptor, contributor] } } diff --git a/man/unconstrain.search.Rd b/man/unconstrain.search.Rd index e0a94af..0acf4c7 100644 --- a/man/unconstrain.search.Rd +++ b/man/unconstrain.search.Rd @@ -8,7 +8,7 @@ unconstrain.search(data, window.size, matrix.profile, profile.index, n.bit = 4, k = Inf) } \arguments{ -\item{data}{a \code{matrix} of \code{numeric}, where each colums is a time series. Accepts \code{vector} (see details), \code{list} and \code{data.frame} too.} +\item{data}{a \code{matrix} of \code{numeric}, where each column is a time series. Accepts \code{vector} (see details), \code{list} and \code{data.frame} too.} \item{window.size}{an \code{int} with the size of the sliding window.} diff --git a/packrat/packrat.lock b/packrat/packrat.lock index 5218792..5365dc2 100644 --- a/packrat/packrat.lock +++ b/packrat/packrat.lock @@ -13,6 +13,12 @@ Source: CRAN Version: 1.0.0 Hash: 6abedd7919c4457604c0aa44529a6683 +Package: DT +Source: CRAN +Version: 0.4 +Hash: a6e844446350a7128c734516fa8215e3 +Requires: crosstalk, htmltools, htmlwidgets, magrittr + Package: PKI Source: CRAN Version: 0.1-5.1 @@ -24,6 +30,11 @@ Source: CRAN Version: 2.2.2 Hash: b2366cd9d2f3851a5704b4e192b985c2 +Package: RColorBrewer +Source: CRAN +Version: 1.1-2 +Hash: c0d56cd15034f395874c870141870c25 + Package: RCurl Source: CRAN Version: 1.95-4.11 @@ -66,12 +77,6 @@ Source: CRAN Version: 0.1-3 Hash: c590d29e555926af053055e23ee79efb -Package: beepr -Source: CRAN -Version: 1.3 -Hash: 3b06c76c8608889c0577b1f9d472a6c0 -Requires: audio, stringr - Package: bit Source: CRAN Version: 1.1-14 @@ -112,19 +117,10 @@ Hash: ae3d74ab94396fc7f6b879f17fb71a12 Requires: R6, processx Package: cli -Source: github -Version: 1.0.0.9002 -Hash: 231fd025f7a15312bfa29af3e10d27c9 -Requires: R6, assertthat, crayon, fansi, glue, progress, selectr, - withr, xml2 -GithubRepo: cli -GithubUsername: r-lib -GithubRef: master -GithubSha1: 1ce51456bd1d8ee703e07065ccb8824862d09e73 -RemoteHost: api.github.com -RemoteRepo: cli -RemoteUsername: r-lib -RemoteSha: 1ce51456bd1d8ee703e07065ccb8824862d09e73 +Source: CRAN +Version: 1.0.0 +Hash: f4239f89feb7ddc65821e4514e9734ae +Requires: assertthat, crayon Package: clipr Source: CRAN @@ -136,65 +132,41 @@ Source: CRAN Version: 1.2.0 Hash: a76a309884277a4fd8a5d741965fbef5 +Package: colorspace +Source: CRAN +Version: 1.3-2 +Hash: 0bf8618b585fa98eb23414cd3ab95118 + Package: commonmark Source: CRAN Version: 1.5 Hash: 432a16a9967055dad6b39f1c14fd6b2c Package: covr -Source: CRAN +Source: github Version: 3.1.0 -Hash: 55eaad0d3e61626cc0c8928985a849fa +Hash: 6022dedb19a9462e0496ae14615810da Requires: crayon, digest, httr, jsonlite, rex, withr - -Package: crancache -Source: github -Version: 0.0.0.9000 -Hash: 534a806e0a083e675c71f60fb3f2b7b3 -Requires: callr, cranlike, curl, desc, digest, parsedate, rappdirs, - withr -GithubRepo: crancache +GithubRepo: covr GithubUsername: r-lib GithubRef: master -GithubSha1: e2185c76b6fcd36c9970cfa22ffd2cb62b13eb53 -RemoteHost: api.github.com -RemoteRepo: crancache -RemoteUsername: r-lib -RemoteSha: e2185c76b6fcd36c9970cfa22ffd2cb62b13eb53 - -Package: cranlike -Source: github -Version: 1.0.1.9001 -Hash: 228d02131e3aa54af9a684864a6511ad -Requires: DBI, RSQLite, debugme, desc -GithubRepo: cranlike -GithubUsername: r-hub -GithubRef: master -GithubSha1: 3c72c14ea25a6cfe7b5585cef871ab1711a5aee9 -RemoteHost: api.github.com -RemoteRepo: cranlike -RemoteUsername: r-hub -RemoteSha: 3c72c14ea25a6cfe7b5585cef871ab1711a5aee9 - -Package: cranlogs -Source: github -Version: 2.1.1 -Hash: 6811357ef92c6f13a4a1c3d1cfc0a9e2 -Requires: httr, jsonlite -GithubRepo: cranlogs -GithubUsername: metacran -GithubRef: master -GithubSha1: 554a99ef6089d5618e6fe64d580aa217bb7558e3 +GithubSha1: e15d96cf088821b6bcbadb89595ed35c3d50f811 RemoteHost: https://api.github.com -RemoteRepo: cranlogs -RemoteUsername: metacran -RemoteSha: 554a99ef6089d5618e6fe64d580aa217bb7558e3 +RemoteRepo: covr +RemoteUsername: r-lib +RemoteSha: e15d96cf088821b6bcbadb89595ed35c3d50f811 Package: crayon Source: CRAN Version: 1.3.4 Hash: ff2840dd9b0d563fc80377a5a45510cd +Package: crosstalk +Source: CRAN +Version: 1.0.0 +Hash: c13adea5906fbe2becfcb5f843b26749 +Requires: R6, ggplot2, htmltools, jsonlite, lazyeval, shiny + Package: curl Source: CRAN Version: 3.2 @@ -207,33 +179,25 @@ Hash: c233690edd9fa17a63f7c8d83c1ca153 Requires: crayon Package: desc -Source: github +Source: CRAN Version: 1.2.0 -Hash: acb5cf9e16dd327a0d0fc6ab6522939d +Hash: a1fd2baa29d4954951e3d1816deab6af Requires: R6, assertthat, crayon, rprojroot -GithubRepo: desc -GithubUsername: r-lib -GithubRef: master -GithubSha1: 4f60833fdb6d1aae4cbf09b7eb293c5fa0770e5c -RemoteHost: api.github.com -RemoteRepo: desc -RemoteUsername: r-lib -RemoteSha: 4f60833fdb6d1aae4cbf09b7eb293c5fa0770e5c Package: devtools Source: github Version: 1.13.6.9000 -Hash: 18814b1ead54eb753df1b2b2e2b40e41 +Hash: dd085b2f37d87787a7aaaa78ac29529f Requires: callr, cli, digest, git2r, httr, jsonlite, memoise, pkgbuild, pkgload, rcmdcheck, rstudioapi, usethis, withr GithubRepo: devtools GithubUsername: r-lib GithubRef: master -GithubSha1: 5bbcac458f7c874e465229c01f07d4ff229d3dfc +GithubSha1: 2d012d171b77fcfb54684ba1472797ccd0950709 RemoteHost: https://api.github.com RemoteRepo: devtools RemoteUsername: r-lib -RemoteSha: 5bbcac458f7c874e465229c01f07d4ff229d3dfc +RemoteSha: 2d012d171b77fcfb54684ba1472797ccd0950709 Package: digest Source: CRAN @@ -274,19 +238,18 @@ Version: 1.2.5 Hash: 6a914517bc7770d6672da55de125c12c Requires: Rcpp +Package: ggplot2 +Source: CRAN +Version: 3.0.0 +Hash: 8332448b76ff31472a1bf6dd31fcddb1 +Requires: digest, gtable, lazyeval, plyr, reshape2, rlang, scales, + tibble, viridisLite, withr + Package: gh -Source: github +Source: CRAN Version: 1.0.1 -Hash: 7d6e51bfd8cb23d0f3d36b95c787a39f +Hash: 0fafa863f1a86a1f1966e5d5b46a48b5 Requires: httr, ini, jsonlite -GithubRepo: gh -GithubUsername: r-lib -GithubRef: master -GithubSha1: a8b645364f59a5d5030ccfd8d074de640d8b72cd -RemoteHost: https://api.github.com -RemoteRepo: gh -RemoteUsername: r-lib -RemoteSha: a8b645364f59a5d5030ccfd8d074de640d8b72cd Package: git2r Source: CRAN @@ -304,6 +267,11 @@ Version: 0.7.1 Hash: 69302be7fe9b4dbb2d1e971e63e4703c Requires: base64enc, crayon, httr, jsonlite, magrittr, mime +Package: gtable +Source: CRAN +Version: 0.2.0 +Hash: cd78381a9d3fea966ac39bd0daaf5554 + Package: highlight Source: CRAN Version: 0.4.7.2 @@ -314,18 +282,18 @@ Source: CRAN Version: 0.7 Hash: 20757f5c393ed0ecf96c9e8e6d8d514c -Package: hms -Source: CRAN -Version: 0.4.2 -Hash: b4096a4f6a6736138e9a825c2baaacf0 -Requires: pkgconfig, rlang - Package: htmltools Source: CRAN Version: 0.3.6 Hash: 87bd72cdfc46f686bbd46b180cb5f0b5 Requires: Rcpp, digest +Package: htmlwidgets +Source: CRAN +Version: 1.2 +Hash: de18b75f31630089b22e30d4b188cfbe +Requires: htmltools, jsonlite, yaml + Package: httpuv Source: CRAN Version: 1.4.5 @@ -365,6 +333,11 @@ Version: 1.20 Hash: 9c6b215d1d02b97586c8232e94533e6a Requires: evaluate, highr, markdown, stringr, yaml +Package: labeling +Source: CRAN +Version: 0.3 +Hash: ecf589b42cd284b03a4beb9665482d3e + Package: later Source: CRAN Version: 0.7.3 @@ -404,6 +377,12 @@ Version: 0.1.1.1 Hash: c7e3ea486421c2fa5b03bb7fcd0415f6 Requires: htmltools, shiny +Package: munsell +Source: CRAN +Version: 0.5.0 +Hash: 247d1c1d72f3072563912ef860758624 +Requires: colorspace + Package: openssl Source: CRAN Version: 1.0.2 @@ -426,18 +405,10 @@ Hash: 3e43f774fa6dfba877caca1aebbeaa6a Requires: cli, crayon, fansi, rlang, utf8 Package: pkgbuild -Source: github +Source: CRAN Version: 1.0.0 -Hash: 6d46ad074349b737b4e96f2b032c9b67 +Hash: 0a49f0fd623849e51386a274c6ebdbd9 Requires: R6, callr, crayon, desc, rprojroot, withr -GithubRepo: pkgbuild -GithubUsername: r-lib -GithubRef: master -GithubSha1: 3d3d6cf487ecffefcd218f0ab5747f569d8f1680 -RemoteHost: https://api.github.com -RemoteRepo: pkgbuild -RemoteUsername: r-lib -RemoteSha: 3d3d6cf487ecffefcd218f0ab5747f569d8f1680 Package: pkgconfig Source: CRAN @@ -464,6 +435,12 @@ Source: CRAN Version: 0.2.0 Hash: 81a8008a5e7858552503935f1abe48aa +Package: plyr +Source: CRAN +Version: 1.8.4 +Hash: 05d65ee369a267f0d0c56604000c69b5 +Requires: Rcpp + Package: praise Source: CRAN Version: 1.0.0 @@ -481,20 +458,6 @@ Version: 3.2.0 Hash: 906405f0bc681c9438826952417d5d5a Requires: R6, assertthat, crayon, ps -Package: progress -Source: github -Version: 1.2.0 -Hash: c2beada98e1d490daf2b221763f3875c -Requires: R6, crayon, hms, prettyunits -GithubRepo: progress -GithubUsername: r-lib -GithubRef: master -GithubSha1: 842852869af44a8618e948485b24cdbaf2829736 -RemoteHost: api.github.com -RemoteRepo: progress -RemoteUsername: r-lib -RemoteSha: 842852869af44a8618e948485b24cdbaf2829736 - Package: promises Source: CRAN Version: 1.0.1 @@ -527,7 +490,7 @@ GithubRepo: rcmdcheck GithubUsername: r-lib GithubRef: master GithubSha1: ad42561aa6e06297367455546b6312dcf59282b6 -RemoteHost: api.github.com +RemoteHost: https://api.github.com RemoteRepo: rcmdcheck RemoteUsername: r-lib RemoteSha: ad42561aa6e06297367455546b6312dcf59282b6 @@ -543,34 +506,11 @@ Version: 2.0.1 Hash: b7f86a340a404c69cfb770dfd2081dd9 Requires: tibble -Package: remotes -Source: github -Version: 1.1.1.9000 -Hash: e92091b6a2e32fb964f5a33d4e063d3b -GithubRepo: remotes -GithubUsername: r-lib -GithubRef: master -GithubSha1: 7a576028506708f56bc5db0bde5491de26648e5f -RemoteHost: api.github.com -RemoteRepo: remotes -RemoteUsername: r-lib -RemoteSha: 7a576028506708f56bc5db0bde5491de26648e5f - -Package: revdepcheck -Source: github -Version: 1.0.0.9000 -Hash: f2091d76552847c80ccd612dcde54851 -Requires: DBI, RSQLite, assertthat, callr, cli, clisymbols, crancache, - crayon, desc, glue, gmailr, jsonlite, knitr, prettyunits, processx, - progress, rcmdcheck, remotes, sessioninfo, whoami, withr, yaml -GithubRepo: revdepcheck -GithubUsername: r-lib -GithubRef: master -GithubSha1: ee4ca3a7747d6f1f4b77edb900100be969fd30ba -RemoteHost: api.github.com -RemoteRepo: revdepcheck -RemoteUsername: r-lib -RemoteSha: ee4ca3a7747d6f1f4b77edb900100be969fd30ba +Package: reshape2 +Source: CRAN +Version: 1.4.3 +Hash: a08472524968be4e233b4c8d0ae5aef1 +Requires: Rcpp, plyr, stringr Package: rex Source: CRAN @@ -628,6 +568,12 @@ Version: 1.0.3 Hash: 44837671df6bf1d0b863dc6f83f42a16 Requires: curl, xml2 +Package: scales +Source: CRAN +Version: 1.0.0 +Hash: 17b6945d25b9288cdf03f5e5005842dc +Requires: R6, RColorBrewer, Rcpp, labeling, munsell, viridisLite + Package: selectr Source: CRAN Version: 0.4-1 @@ -657,10 +603,16 @@ Source: CRAN Version: 0.1.7 Hash: d093478ac90064e670cd4bf1a99b47b6 +Package: spelling +Source: CRAN +Version: 1.2 +Hash: 084f65bd10a7253f957b616a3a257194 +Requires: commonmark, hunspell, knitr, xml2 + Package: stringi Source: CRAN -Version: 1.2.4 -Hash: 03ab60ef7fa4627b38ad67c95ce6b04c +Version: 1.1.7 +Hash: d3dbb18da9a7b73a5b59416e33ad2cbd Package: stringr Source: CRAN @@ -694,25 +646,22 @@ Hash: a149d4e6a2f7d6422e063a19cca52bb9 Requires: xfun Package: usethis -Source: github -Version: 1.4.0.9000 -Hash: 7cc9190f229ba4971678535221c3f172 +Source: CRAN +Version: 1.4.0 +Hash: bdf0ce7802818c5dfc592dd73d62db5b Requires: clipr, clisymbols, crayon, curl, desc, fs, gh, git2r, glue, rlang, rprojroot, rstudioapi, whisker -GithubRepo: usethis -GithubUsername: r-lib -GithubRef: master -GithubSha1: 01dd42bca6a2f7d377e6dcedea7da23f29fe7678 -RemoteHost: https://api.github.com -RemoteRepo: usethis -RemoteUsername: r-lib -RemoteSha: 01dd42bca6a2f7d377e6dcedea7da23f29fe7678 Package: utf8 Source: CRAN Version: 1.1.4 Hash: f3f97ce59092abc8ed3fd098a59e236c +Package: viridisLite +Source: CRAN +Version: 0.3.0 +Hash: 78bb072c4f9e729a283d4c40ec93f9c6 + Package: whisker Source: CRAN Version: 0.3-2 diff --git a/packrat/packrat.opts b/packrat/packrat.opts index fe842a8..b7bdb6d 100644 --- a/packrat/packrat.opts +++ b/packrat/packrat.opts @@ -6,7 +6,7 @@ vcs.ignore.src: FALSE external.packages: local.repos: load.external.packages.on.startup: TRUE -ignored.packages: +ignored.packages: tsmp ignored.directories: data inst diff --git a/tests/testthat/test.basics.R b/tests/testthat/test.basics.R index 21be816..0991a95 100644 --- a/tests/testthat/test.basics.R +++ b/tests/testthat/test.basics.R @@ -1,15 +1,21 @@ context("Testing if basic functions are ok") library(tsmp) w <- 30 -ref.data <- toy_data$data[,1] -query.data <- toy_data$data[,1] +ref.data <- toy_data$data[, 1] +query.data <- toy_data$data[, 1] d.size <- length(ref.data) q.size <- length(query.data) +test_that("Errors", { + # big window size + expect_error(fast.movsd(toy_data$data[, 1], 1), regexp = "must be at least 2") + expect_error(fast.movsd(toy_data$data[1:100, 1], 500), regexp = "is too large") +}) + pre <- mass.pre(ref.data, d.size, query.data, q.size, w) res <- mass(pre$data.fft, query.data[1:w], d.size, w, pre$data.mean, pre$data.sd, pre$query.mean[1], pre$query.sd[1]) -movsd <- fast.movsd(toy_data$data[,1], 30) -movavg <- fast.movavg(toy_data$data[,1], 30) +movsd <- fast.movsd(toy_data$data[, 1], 30) +movavg <- fast.movavg(toy_data$data[, 1], 30) test_that("Fast Moving SD is ok", { expect_known_hash(round(movsd, 3), "ffda40fd35") diff --git a/tests/testthat/test.find.chains.R b/tests/testthat/test.find.chains.R new file mode 100644 index 0000000..d939ca6 --- /dev/null +++ b/tests/testthat/test.find.chains.R @@ -0,0 +1,14 @@ +context("Testing Time Series Chains") +library(tsmp) + +w <- 50 +data <- gait_data +mp <- stamp(data, window.size = w, exclusion.zone = 1 / 4, verbose = 0) +res <- find.chains(mp) + +test_that("Find Chains", { + expect_equal(length(res), 2) + expect_equal(length(res$chains), 58) + expect_equal(length(res$best), 6) + expect_known_hash(res$chains, "d7c3f43152") +}) diff --git a/tests/testthat/test.fluss.R b/tests/testthat/test.fluss.R index 94240f6..02b751c 100644 --- a/tests/testthat/test.fluss.R +++ b/tests/testthat/test.fluss.R @@ -4,10 +4,18 @@ library(tsmp) data <- fluss_data$tilt.abp$data[1:1000] w <- 10 truth <- 400 +nseg <- 3 mp <- mstomp(data, w, verbose = 0) cac <- fluss.cac(mp$pi, w) -segments <- fluss.extract(cac, 3, w) +segments <- fluss.extract(cac, nseg, w) score <- fluss.score(truth, segments, length(data)) +res <- fluss(t(data), w, nseg, gtruth = truth, verbose = 0) +res.nt <- fluss(data, w, nseg, verbose = 0) + +test_that("Errors", { + # big window size + expect_error(fluss(table(data), w, nseg, gtruth = truth, verbose = 0), regexp = "Unknown type of data") +}) test_that("Corrected Arc Count", { expect_equal(round(mean(cac), 4), 0.9941) @@ -23,3 +31,20 @@ test_that("Segments found", { test_that("Score", { expect_equal(score, 0.259) }) + +test_that("Full fluss", { + expect_equal(res$score, score) + expect_equal(res$segments, segments) + expect_equal(res$segments, res.nt$segments) + expect_equal(res$mp, res.nt$mp) + expect_equal(res$pi, res.nt$pi) + expect_equal(res$cac, res.nt$cac) + expect_equal(round(mean(res$cac), 4), round(mean(cac), 4)) + expect_equal(round(mean(res$cac), 4), round(mean(res.nt$cac), 4)) + expect_equal(round(sd(res$cac), 4), round(sd(cac), 4)) + expect_equal(round(sd(res$cac), 4), round(sd(res.nt$cac), 4)) + expect_equal(round(min(res$cac), 4), round(min(cac), 4)) + expect_equal(round(min(res$cac), 4), round(min(res.nt$cac), 4)) + expect_equal(max(res$cac), max(cac)) + expect_equal(max(res$cac), max(res.nt$cac)) +}) diff --git a/tests/testthat/test.mstomp.search.R b/tests/testthat/test.mstomp.search.R new file mode 100644 index 0000000..e9be136 --- /dev/null +++ b/tests/testthat/test.mstomp.search.R @@ -0,0 +1,34 @@ +context("Testing mSTOMP Search") +library(tsmp) + +w <- toy_data$sub.len +mp <- mstomp(toy_data$data[1:200, ], w, verbose = 0) +motifs <- guide.search(list(toy_data$data[1:200, 1], toy_data$data[1:200, 2], toy_data$data[1:200, 3]), w, mp$mp, mp$pi, 2) +motifs.t <- guide.search(t(toy_data$data[1:200, ]), w, mp$mp, mp$pi, 2) +motifs.u <- unconstrain.search(list(toy_data$data[1:200, 1], toy_data$data[1:200, 2], toy_data$data[1:200, 3]), w, mp$mp, mp$pi, 2) +motifs.ut <- unconstrain.search(t(toy_data$data[1:200, ]), w, mp$mp, mp$pi, 2) + +test_that("Errors", { + # unknown type + expect_error(unconstrain.search(table(toy_data$data[1:200, ]), w, mp$mp, mp$pi, 2), regexp = "Unknown type of data") + expect_error(guide.search(table(toy_data$data[1:200, ]), w, mp$mp, mp$pi, 2), regexp = "Unknown type of data") +}) + +test_that("Message", { + mpnm <- mstomp(toy_data$data[1:200, ], 100, verbose = 0) + expect_message(unconstrain.search(toy_data$data[1:200, ], 100, mpnm$mp, mpnm$pi, 2), regexp = "No motifs found") +}) + +test_that("Guide Search", { + expect_equal(motifs, motifs.t) + expect_equal(guide.search(as.data.frame(toy_data$data[1:200, ]), w, mp$mp, mp$pi, 2), motifs) + expect_equal(motifs$motif.idx, c(44, 108)) + expect_equal(motifs$motif.dim, list(c(2, 3), c(2, 3))) +}) + +test_that("Unguide Search", { + expect_equal(motifs.u, motifs.ut) + expect_equal(unconstrain.search(as.data.frame(toy_data$data[1:200, ]), w, mp$mp, mp$pi, 2), motifs.u) + expect_equal(motifs.u$motif.idx, c(33, 102, 57, 9, 127, 81)) + expect_equal(motifs.u$motif.dim, list(1, 1, 1, 1, 1, 3)) +}) diff --git a/tests/testthat/test.sdts.R b/tests/testthat/test.sdts.R new file mode 100644 index 0000000..d930db7 --- /dev/null +++ b/tests/testthat/test.sdts.R @@ -0,0 +1,40 @@ +context("Testing SDTS functions") +library(tsmp) + +test_that("Errors", { + # big window size + expect_error(sdts.train(test_data$train$data[1:100], test_data$train$label[1:110], window.size = 5000), regexp = "Time series is too short") + + # small window size + expect_error(sdts.train(test_data$train$data[1:100], test_data$train$label[1:100], window.size = 2), regexp = "Subsequence length must") + + # unknown data type + expect_error(sdts.train(table(test_data$train$data[1:100]), test_data$train$label[1:100], window.size = 110), regexp = "Unknown type") +}) + +w <- c(110, 220, 330) +subs <- 20000:60000 +tr_data <- as.data.frame(test_data$train$data[subs]) +tr_label <- test_data$train$label[subs] +te_data <- test_data$test$data[subs] +te_label <- test_data$test$label[subs] +model <- sdts.train(tr_data, tr_label, w, verbose = 0) +predict <- sdts.predict(model, te_data, round(mean(w))) +pred.score <- sdts.f.score(te_label, predict, 1) + +test_that("SDTS Train", { + expect_equal(round(model$score, 3), 0.889) + expect_equal(round(model$score.hist, 3), c(0.667, 0.889)) + expect_equal(round(sum(model$pattern[[1]] + model$pattern[[2]]) / sd(model$pattern[[1]]), 3), -8289.256) + expect_equal(round(model$thold, 3), c(9.125, 2.069)) +}) + +test_that("SDTS Predict", { + expect_known_hash(predict, "72ddd7b33b") +}) + +test_that("SDTS F Score", { + expect_equal(pred.score$f.score, 0.8) + expect_equal(round(pred.score$precision, 4), 0.8) + expect_equal(pred.score$recall, 0.8) +}) diff --git a/tests/testthat/test.simple.R b/tests/testthat/test.simple.R new file mode 100644 index 0000000..eb82b48 --- /dev/null +++ b/tests/testthat/test.simple.R @@ -0,0 +1,17 @@ +context("Testing SiMPle Fast") +library(tsmp) + +w <- 30 +data <- toy_data$data # 3 dimensions matrix +if (skip_on_cran()) { + result <- simple.fast(data, w, verbose = 2) +} else { + result <- simple.fast(data, w, verbose = 0) +} + +test_that("SiMPle Results", { + expect_equal(round(sum(result$mp), 3), 806.132) + expect_equal(round(sd(result$mp), 3), 0.575) + expect_equal(sum(result$pi), 135450) + expect_equal(round(sd(result$pi), 3), 151.06) +}) diff --git a/tests/testthat/test.stamps.R b/tests/testthat/test.stamps.R index d251b1f..6f6e6a6 100644 --- a/tests/testthat/test.stamps.R +++ b/tests/testthat/test.stamps.R @@ -4,56 +4,56 @@ library(tsmp) if (skip_on_cran()) { test_that("Errors", { # big window size - expect_error(mstomp(toy_data$data[1:200, ], window.size = 500, verbose = 0), regexp = "too short relative") - expect_error(mstomp.par(toy_data$data[1:200, ], window.size = 500, verbose = 0), regexp = "too short relative") - expect_error(stamp(toy_data$data[1:200, ], window.size = 500, verbose = 0), regexp = "too short relative") - expect_error(stamp.par(toy_data$data[1:200, ], window.size = 500, verbose = 0), regexp = "too short relative") + expect_error(mstomp(toy_data$data[1:200, ], window.size = 500), regexp = "too short relative") + expect_error(mstomp.par(toy_data$data[1:200, ], window.size = 500), regexp = "too short relative") + expect_error(stamp(toy_data$data[1:200, ], window.size = 500), regexp = "too short relative") + expect_error(stamp.par(toy_data$data[1:200, ], window.size = 500), regexp = "too short relative") # intersect - expect_error(mstomp(toy_data$data[1:200, ], window.size = 30, must.dim = c(1, 2), exc.dim = c(2, 3), verbose = 0), regexp = "presented in both") - expect_error(mstomp.par(toy_data$data[1:200, ], window.size = 30, must.dim = c(1, 2), exc.dim = c(2, 3), verbose = 0), regexp = "presented in both") + expect_error(mstomp(toy_data$data[1:200, ], window.size = 30, must.dim = c(1, 2), exc.dim = c(2, 3)), regexp = "presented in both") + expect_error(mstomp.par(toy_data$data[1:200, ], window.size = 30, must.dim = c(1, 2), exc.dim = c(2, 3)), regexp = "presented in both") # too many must.dim - expect_error(mstomp(toy_data$data[1:200, ], window.size = 30, must.dim = c(1, 2, 3, 4), verbose = 0), regexp = "must have dimension must be less") - expect_error(mstomp.par(toy_data$data[1:200, ], window.size = 30, must.dim = c(1, 2, 3, 4), verbose = 0), regexp = "must have dimension must be less") + expect_error(mstomp(toy_data$data[1:200, ], window.size = 30, must.dim = c(1, 2, 3, 4)), regexp = "must have dimension must be less") + expect_error(mstomp.par(toy_data$data[1:200, ], window.size = 30, must.dim = c(1, 2, 3, 4)), regexp = "must have dimension must be less") # too many exc.dim - expect_error(mstomp(toy_data$data[1:200, ], window.size = 30, exc.dim = c(1, 2, 3, 4), verbose = 0), regexp = "exclusion dimension must be less") - expect_error(mstomp.par(toy_data$data[1:200, ], window.size = 30, exc.dim = c(1, 2, 3, 4), verbose = 0), regexp = "exclusion dimension must be less") + expect_error(mstomp(toy_data$data[1:200, ], window.size = 30, exc.dim = c(1, 2, 3, 4)), regexp = "exclusion dimension must be less") + expect_error(mstomp.par(toy_data$data[1:200, ], window.size = 30, exc.dim = c(1, 2, 3, 4)), regexp = "exclusion dimension must be less") # small window size - expect_error(stamp(toy_data$data[1:200, ], window.size = 2, verbose = 0), regexp = "Subsequence length") - expect_error(stamp.par(toy_data$data[1:200, ], window.size = 2, verbose = 0), regexp = "Subsequence length") - expect_error(mstomp(toy_data$data[1:200, ], window.size = 2, verbose = 0), regexp = "Subsequence length") - expect_error(mstomp.par(toy_data$data[1:200, ], window.size = 2, verbose = 0), regexp = "Subsequence length") + expect_error(stamp(toy_data$data[1:200, ], window.size = 2), regexp = "Subsequence length") + expect_error(stamp.par(toy_data$data[1:200, ], window.size = 2), regexp = "Subsequence length") + expect_error(mstomp(toy_data$data[1:200, ], window.size = 2), regexp = "Subsequence length") + expect_error(mstomp.par(toy_data$data[1:200, ], window.size = 2), regexp = "Subsequence length") # unknown data type - expect_error(stamp(table(rpois(100, 5)), window.size = 30, verbose = 0), regexp = "Unknown type") - expect_error(stamp.par(table(rpois(100, 5)), window.size = 30, verbose = 0), regexp = "Unknown type") - expect_error(mstomp(table(rpois(100, 5)), window.size = 30, verbose = 0), regexp = "Unknown type") - expect_error(mstomp.par(table(rpois(100, 5)), window.size = 30, verbose = 0), regexp = "Unknown type") + expect_error(stamp(table(rpois(100, 5)), window.size = 30), regexp = "Unknown type") + expect_error(stamp.par(table(rpois(100, 5)), window.size = 30), regexp = "Unknown type") + expect_error(mstomp(table(rpois(100, 5)), window.size = 30), regexp = "Unknown type") + expect_error(mstomp.par(table(rpois(100, 5)), window.size = 30), regexp = "Unknown type") + }) + + test_that("Finish", { + Sys.sleep(0.5) + expect_message(stamp(toy_data$data[1:200, 1], window.size = 30), regex = "Finished") + Sys.sleep(0.5) + expect_message(stamp.par(toy_data$data[1:200, 1], window.size = 30), regex = "Finished") + Sys.sleep(0.5) + expect_message(mstomp(toy_data$data[1:200, 1], window.size = 30), regex = "Finished") + Sys.sleep(0.5) + expect_message(mstomp.par(toy_data$data[1:200, 1], window.size = 30), regex = "Finished") }) stamp.test <- stamp(toy_data$data[1:200, 1], window.size = 30, verbose = 0) - Sys.sleep(0.5) stamp.join.test <- stamp(toy_data$data[1:200, 1], toy_data$data[1:100, 2], window.size = 30, verbose = 0) - Sys.sleep(0.5) stamp.par.test <- stamp.par(toy_data$data[1:200, 1], window.size = 30, verbose = 0) - Sys.sleep(0.5) stamp.par.join.test <- stamp.par(toy_data$data[1:200, 1], toy_data$data[1:100, 2], window.size = 30, verbose = 0) - Sys.sleep(0.5) stomp.test <- mstomp(toy_data$data[1:200, 1], window.size = 30, verbose = 0) - Sys.sleep(0.5) stomp.par.test <- mstomp.par(toy_data$data[1:200, 1], window.size = 30, verbose = 0) - Sys.sleep(0.5) mstomp.test <- mstomp(toy_data$data[1:200, ], window.size = 30, verbose = 0) - Sys.sleep(0.5) mstomp.test.must <- mstomp(toy_data$data[1:200, ], window.size = 30, must.dim = c(1, 2), verbose = 0) - Sys.sleep(0.5) mstomp.test.exc <- mstomp(toy_data$data[1:200, ], window.size = 30, exc.dim = c(1, 2), verbose = 0) - Sys.sleep(0.5) mstomp.par.test <- mstomp.par(toy_data$data[1:200, ], window.size = 30, verbose = 0) - Sys.sleep(0.5) mstomp.par.test.must <- mstomp.par(toy_data$data[1:200, ], window.size = 30, must.dim = c(1, 2), verbose = 0) - Sys.sleep(0.5) mstomp.par.test.exc <- mstomp.par(toy_data$data[1:200, ], window.size = 30, exc.dim = c(1, 2), verbose = 0) test_that("Result hashes", {