Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
franzbischoff committed Oct 16, 2018
2 parents 080f764 + e4cc4cf commit 8fea7ce
Show file tree
Hide file tree
Showing 69 changed files with 855 additions and 177 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CONTRIBUTING
================
Francisco Bischoff
\- 13 Oct 2018
\- 16 Oct 2018

<!-- CONTRIBUTING.md is generated from CONTRIBUTING.Rmd Please edit that file -->

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: tsmp
Type: Package
Title: Time Series with Matrix Profile
Version: 0.3.1.9028
Version: 0.3.1.9031
Authors@R: c(
person("Francisco", "Bischoff", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "https://orcid.org/0000-0002-5301-8672")),
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ S3method(plot,Motif)
S3method(plot,MultiMatrixProfile)
S3method(plot,MultiMotif)
S3method(plot,Salient)
S3method(plot,SimpleMatrixProfile)
S3method(print,ArcCount)
S3method(print,Chain)
S3method(print,Fluss)
Expand All @@ -18,6 +19,7 @@ S3method(print,Motif)
S3method(print,MultiMatrixProfile)
S3method(print,MultiMotif)
S3method(print,Salient)
S3method(print,SimpleMatrixProfile)
export("%>%")
export("%T>%")
export(as.arccount)
Expand Down
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ tsmp 0.3.1.9000
- Fixed SCRIMP and added PRE-SCRIMP, so this is the SCRIMP++. AB-join
not yet implemented.
- Changed progress bar for a better one from `progress` package.
- Added Print and Plot to SiMPle. Issue \#24
- Added Print and Plot to Salient.

tsmp 0.3.1
==========
Expand Down
2 changes: 2 additions & 0 deletions NEWS.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ knitr::opts_chunk$set(
* Changed verbose mode, added one more step to separate messages from progression bar.
* Fixed SCRIMP and added PRE-SCRIMP, so this is the SCRIMP++. AB-join not yet implemented.
* Changed progress bar for a better one from `progress` package.
* Added Print and Plot to SiMPle. Issue #24
* Added Print and Plot to Salient.

# tsmp 0.3.1

Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NEWS
================
Francisco Bischoff
\- 13 Oct 2018
\- 16 Oct 2018

<!-- NEWS.md is generated from NEWS.Rmd. Please edit that file -->

Expand All @@ -16,6 +16,8 @@ Francisco Bischoff
- Fixed SCRIMP and added PRE-SCRIMP, so this is the SCRIMP++. AB-join
not yet implemented.
- Changed progress bar for a better one from `progress` package.
- Added Print and Plot to SiMPle. Issue \#24
- Added Print and Plot to Salient.

# tsmp 0.3.1

Expand Down
45 changes: 42 additions & 3 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,43 @@ plot.MultiMatrixProfile <- function(x, ylab = "distance", xlab = "index", main =
graphics::par(def_par)
}

#' @export
#' @keywords hplot
#' @name plot
#'
plot.SimpleMatrixProfile <- function(x, ylab = "distance", xlab = "index", main = "SiMPle Matrix Profile", ...) {
def_par <- graphics::par(no.readonly = TRUE)
allmatrix <- FALSE
n_dim <- ncol(x$mp)

if (!is.null(x$lmp) && !all(x$lpi == -1)) {
allmatrix <- TRUE
}

if (allmatrix == TRUE) {
graphics::layout(matrix(seq_len(3 * n_dim), ncol = 3, byrow = TRUE))
}
graphics::par(
mar = c(4.1, 4.1, 2.1, 2.1),
oma = c(1, 1, 3, 0), cex.lab = 1.5
)
for (i in seq_len(n_dim)) {
graphics::plot(x$mp[, i], type = "l", main = paste0("Matrix Profile (w = ", x$w, "; ez = ", x$ez, ")"), ylab = ylab, xlab = xlab, ...)
}
graphics::mtext(text = main, font = 2, cex = 1.5, outer = TRUE)

if (allmatrix == TRUE) {
for (i in seq_len(n_dim)) {
graphics::plot(x$rmp[, i], type = "l", main = "Right Matrix Profile", ylab = ylab, xlab = xlab, ...)
}
for (i in seq_len(n_dim)) {
graphics::plot(x$lmp[, i], type = "l", main = "Left Matrix Profile", ylab = ylab, xlab = xlab, ...)
}
}

graphics::par(def_par)
}

#' @export
#' @keywords hplot
#' @name plot
Expand Down Expand Up @@ -560,7 +597,7 @@ plot.Salient <- function(x, data, main = "Salient Subsections", xlab = "index",
y_max <- max(data)

mds <- salient_mds(x, data)
idxs <- sort(x$salient$indexes[,1])
idxs <- sort(x$salient$indexes[, 1])

# layout: matrix profile on top, motifs below.
graphics::layout(matrix(c(1, 1, 1, 0, 2, 0), ncol = 3, byrow = TRUE))
Expand All @@ -569,8 +606,10 @@ plot.Salient <- function(x, data, main = "Salient Subsections", xlab = "index",
graphics::plot(plot_data, type = "l", main = plot_subtitle, xlab = xlab, ylab = ylab)
graphics::mtext(text = main, font = 2, cex = 1.5, outer = TRUE)

graphics::rect(idxs, y_min, xright = idxs + x$w, y_max, border = NA,
col = grDevices::adjustcolor("blue", alpha.f = 0.1))
graphics::rect(idxs, y_min,
xright = idxs + x$w, y_max, border = NA,
col = grDevices::adjustcolor("blue", alpha.f = 0.1)
)

graphics::plot(mds, main = "MDS")

Expand Down
28 changes: 28 additions & 0 deletions R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,34 @@ print.MultiMatrixProfile <- function(x, ...) {
}
}

#' Prints a SiMPle Matrix Profile
#'
#' @param x a TSMP object of class `SimpleMatrixProfile`.
#' @param ... additional arguments ignored.
#' @export
#' @keywords internal
#' @noRd

print.SimpleMatrixProfile <- function(x, ...) {
cat("SiMPle Matrix Profile\n")
cat("---------------------\n")

cat("Profile size =", nrow(x$mp), "\n")
cat("Dimensions =", x$n_dim, "\n")
cat("Window size =", x$w, "\n")
cat("Exclusion zone =", round(x$w * x$ez + vars()$eps), "\n")

if (!is.null(x$data)) {
set <- length(x$data)
obs <- nrow(x$data[[1]])
dim <- ncol(x$data[[1]])
cat(
"Contains", set, ifelse(set > 1, "sets", "set"), "of data with", obs, "observations and", dim,
ifelse(dim > 1, "dimensions", "dimension"), "\n"
)
}
}

#' Prints a CAC profile
#'
#' @param x a TSMP object of class `ArcCount`.
Expand Down
2 changes: 1 addition & 1 deletion R/salient.R
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ salient_score <- function(.mp, gtruth) {
}
}

cutoff <- which(diff(.mp$salient$idx_bit_size[,b]) > 0)[1] - 1
cutoff <- which(diff(.mp$salient$idx_bit_size[, b]) > 0)[1] - 1

if (!is.na(cutoff) && cutoff > 0) {
hit_miss <- hit_miss[1:cutoff]
Expand Down
2 changes: 1 addition & 1 deletion R/scrimp.R
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ scrimp <- function(..., window_size, exclusion_zone = 1 / 2, verbose = 2, s_size
curdistance[i:num_queries] <-
sqrt(abs(2 * (window_size -
(curlastz[i:num_queries] - # x_term
window_size * pre$query_mean[i:num_queries] * pre$data_mean[1:(num_queries - i + 1)]) /
window_size * pre$query_mean[i:num_queries] * pre$data_mean[1:(num_queries - i + 1)]) /
(pre$query_sd[i:num_queries] * pre$data_sd[1:(num_queries - i + 1)])
)))

Expand Down
3 changes: 2 additions & 1 deletion R/simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @param verbose an `int`. See details. (Default is `2`).
#'
#' @return Returns a `SimpleMatrixProfile` object, a `list` with the matrix profile `mp`, profile index `pi`,
#' window size `w` and exclusion zone `ez`.
#' number of dimensions `n_dim`, window size `w` and exclusion zone `ez`.
#'
#' @export
#' @references * Silva D, Yeh C, Batista G, Keogh E. Simple: Assessing Music Similarity Using
Expand Down Expand Up @@ -220,6 +220,7 @@ simple_fast <- function(..., window_size, exclusion_zone = 1 / 2, verbose = 2) {
mp = as.matrix(matrix_profile), pi = as.matrix(profile_index),
rmp = NULL, rpi = NULL,
lmp = NULL, lpi = NULL,
n_dim = n_dim,
w = window_size,
ez = ez
)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
README
================
Francisco Bischoff
\- 13 Oct 2018
\- 16 Oct 2018

<!-- README.md is generated from README.Rmd. Please edit that file -->

Expand Down
2 changes: 1 addition & 1 deletion docs/CODE_OF_CONDUCT.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/CONTRIBUTING.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/articles/press.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/as.matrixprofile.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/av_apply.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/av_complexity.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/av_hardlimit_artifact.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/av_motion_artifact.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/av_stop_word.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/av_zerocrossing.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/fast_movavg.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8fea7ce

Please sign in to comment.