Skip to content

Commit

Permalink
Fixed little issues pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
franzbischoff committed Aug 20, 2018
1 parent f173bda commit 65254e9
Show file tree
Hide file tree
Showing 72 changed files with 327 additions and 266 deletions.
3 changes: 2 additions & 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.2.13.9053
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"), comment = c(ORCID = "https://orcid.org/0000-0002-9807-2963")),
Expand All @@ -15,6 +15,7 @@ URL: https://github.com/franzbischoff/tsmp
BugReports: https://github.com/franzbischoff/tsmp/issues
Depends: R (>= 2.10), audio, doSNOW, parallel, foreach
Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.0
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export(stamp)
export(stamp.par)
export(unconstrain.search)
import(audio)
import(beepr)
import(doSNOW)
import(foreach)
import(parallel)
2 changes: 1 addition & 1 deletion R/fluss.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion R/m_guide_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()]).
Expand Down
2 changes: 1 addition & 1 deletion R/m_unconstrain_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()]).
Expand Down
28 changes: 27 additions & 1 deletion R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
6 changes: 3 additions & 3 deletions R/mstomp.R
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
Expand Down Expand Up @@ -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(audio::play(sounds[[1]]), TRUE)
on.exit(beep(sounds[[1]]), TRUE)
}

## initialization
Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 3 additions & 4 deletions R/mstomp_par.R
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
Expand All @@ -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 audio 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
Expand Down Expand Up @@ -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(audio::play(sounds[[1]]), TRUE)
on.exit(beep(sounds[[1]]), TRUE)
}

## initialize variable
Expand Down
2 changes: 1 addition & 1 deletion R/sdts_predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
6 changes: 3 additions & 3 deletions R/sdts_train.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(audio::play(sounds[[1]]), TRUE)
on.exit(beep(sounds[[1]]), TRUE)
}

for (i in 1:n.window.size) {
Expand Down Expand Up @@ -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
#'
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions R/simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' `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 `list` and `data.frame` too.
#' @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`).
Expand Down Expand Up @@ -76,7 +76,7 @@ simple.fast <- function(data, window.size, exclusion.zone = 1 / 2, verbose = 2)
on.exit(close(pb))
}
if (verbose > 1) {
on.exit(audio::play(sounds[[1]]), TRUE)
on.exit(beep(sounds[[1]]), TRUE)
}

## compute necessary values
Expand Down
4 changes: 2 additions & 2 deletions R/stamp.R
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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(audio::play(sounds[[1]]), TRUE)
on.exit(beep(sounds[[1]]), TRUE)
}
# anytime must return the result always
on.exit(return(list(
Expand Down
7 changes: 3 additions & 4 deletions R/stamp_par.R
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
#'
Expand All @@ -25,7 +25,6 @@
#' @references Website: <http://www.cs.ucr.edu/~eamonn/MatrixProfile.html>
#'
#' @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]
Expand All @@ -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]]
Expand Down Expand Up @@ -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(audio::play(sounds[[1]]), TRUE)
on.exit(beep(sounds[[1]]), TRUE)
}
# anytime must return the result always
on.exit(return(list(
Expand Down
4 changes: 2 additions & 2 deletions R/toy_data.R
Original file line number Diff line number Diff line change
@@ -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/}
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ knitr::opts_chunk$set(
```{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"
```
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Francisco Bischoff
[![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)

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.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.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/authors.html

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

6 changes: 3 additions & 3 deletions docs/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/news/index.html

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

Loading

0 comments on commit 65254e9

Please sign in to comment.