Computes the Matrix Profile and Profile Index for Univariate Time Series.
a matrix
or a vector
. If a second time series is supplied it will be a join matrix
profile.
an int
. Size of the sliding window.
a numeric
. Size of the exclusion zone, based on window size (default is
1/2
). See details.
an int
. See details. (Default is 2
).
an int
. Number of workers for parallel. (Default is 2
).
Returns a MatrixProfile
object, a list
with the matrix profile mp
, profile index pi
left and right matrix profile lmp
, rmp
and profile index lpi
, rpi
, window size w
and
exclusion zone ez
.
The Matrix Profile, has the potential to revolutionize time series data mining because of its
generality, versatility, simplicity and scalability. In particular it has implications for time
series motif discovery, time series joins, shapelet discovery (classification), density
estimation, semantic segmentation, visualization, rule discovery, clustering etc. verbose
changes how much information is printed by this function; 0
means nothing, 1
means text, 2
adds the progress bar, 3
adds the finish sound. exclusion_zone
is used to avoid trivial
matches; if a query data is provided (join similarity), this parameter is ignored.
stomp_par()
: Parallel version.
stomp()
: Single thread version.
Zhu Y, Zimmerman Z, Senobari NS, Yeh CM, Funning G. Matrix Profile II : Exploiting a Novel Algorithm and GPUs to Break the One Hundred Million Barrier for Time Series Motifs and Joins. Icdm. 2016 Jan 22;54(1):739-48.
Other matrix profile computations:
mstomp_par()
,
scrimp()
,
stamp_par()
,
tsmp()
,
valmod()
mp <- stomp(mp_toy_data$data[1:200, 1], window_size = 30, verbose = 0)
# \donttest{
#' # using threads
mp <- stomp_par(mp_toy_data$data[1:400, 1], window_size = 30, verbose = 0)
#> Error in { work_len <- length(idx_work[[i]]) pro_muls <- matrix(Inf, matrix_profile_size, 1) pro_idxs <- matrix(-Inf, matrix_profile_size, 1) if (join) { pro_muls_right <- pro_muls_left <- NULL pro_idxs_right <- pro_idxs_left <- NULL } else { pro_muls_right <- pro_muls_left <- pro_muls pro_idxs_right <- pro_idxs_left <- pro_idxs } dist_pro <- matrix(0, matrix_profile_size, 1) last_product <- matrix(0, matrix_profile_size, 1) drop_value <- matrix(0, 1, 1) for (j in 1:work_len) { idx_st <- idx_work[[i]][1] idx_ed <- idx_work[[i]][work_len] idx <- idx_work[[i]][j] query_window <- as.matrix(query[idx:(idx + window_size - 1), 1]) if (j == 1) { nni <- dist_profile(data, query, nn, index = idx) dist_pro[, 1] <- nni$distance_profile last_product[, 1] <- nni$last_product } else { last_product[2:(data_size - window_size + 1), 1] <- last_product[1:(data_size - window_size), 1] - data[1:(data_size - window_size), 1] * drop_value + data[(window_size + 1):data_size, 1] * query_window[window_size, 1] last_product[1, 1] <- first_product[idx, 1] dist_pro <- 2 * (window_size - (last_product - window_size * nni$par$data_mean * nni$par$query_mean[idx])/(nni$par$data_sd * nni$par$query_sd[idx])) } dist_pro[dist_pro < 0] <- 0 dist_pro <- sqrt(dist_pro) drop_value <- query_window[1, 1] if (exclusion_zone > 0) { exc_st <- max(1, idx - exclusion_zone) exc_ed <- min(matrix_profile_size, idx + exclusion_zone) dist_pro[exc_st:exc_ed, 1] <- Inf } dist_pro[nni$par$data_sd < vars()$eps] <- Inf if (skip_location[idx] || any(nni$par$query_sd[idx] < vars()$eps)) { dist_pro[] <- Inf } dist_pro[skip_location] <- Inf if (!join) { ind <- (dist_pro[idx:matrix_profile_size] < pro_muls_left[idx:matrix_profile_size]) ind <- c(rep(FALSE, (idx - 1)), ind) pro_muls_left[ind] <- dist_pro[ind] pro_idxs_left[which(ind)] <- idx ind <- (dist_pro[1:idx] < pro_muls_right[1:idx]) ind <- c(ind, rep(FALSE, matrix_profile_size - idx)) pro_muls_right[ind] <- dist_pro[ind] pro_idxs_right[which(ind)] <- idx } ind <- (dist_pro < pro_muls) pro_muls[ind] <- dist_pro[ind] pro_idxs[which(ind)] <- idx } res <- list(pro_muls = pro_muls, pro_idxs = pro_idxs, pro_muls_left = pro_muls_left, pro_idxs_left = pro_idxs_left, pro_muls_right = pro_muls_right, pro_idxs_right = pro_idxs_right) res}: task 1 failed - "could not find function "mass_v3""
ref_data <- mp_toy_data$data[, 1]
query_data <- mp_toy_data$data[, 2]
# self similarity
mp <- stomp(ref_data, window_size = 30)
#> Finished in 0.07 secs
# join similarity
mp2 <- stomp(ref_data, query_data, window_size = 30)
#> Finished in 0.05 secs
# }