Skip to content

Commit

Permalink
Finish v0.3.4
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
franzbischoff committed Feb 24, 2019
2 parents 73ded23 + ce6b993 commit 664c20e
Show file tree
Hide file tree
Showing 129 changed files with 4,681 additions and 2,587 deletions.
86 changes: 86 additions & 0 deletions API-v0.3.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# API for tsmp package

## Exported functions

as.arccount(.mp)
as.chain(.mp)
as.discord(.mp)
as.fluss(.mp)
as.matrixprofile(.mp)
as.motif(.mp)
as.multimatrixprofile(.mp)
as.multimotif(.mp)
as.salient(.mp)
as.valmod(.mp)
av_apply(.mp)
av_complexity(.mp, data, dilution_factor = 0, apply = FALSE)
av_hardlimit_artifact(.mp, data, apply = FALSE)
av_motion_artifact(.mp, data, apply = FALSE)
av_stop_word(.mp, data, stop_word_loc, exclusion_zone = NULL, threshold = 0.1, apply = FALSE)
av_zerocrossing(.mp, data, apply = FALSE)
fast_movavg(data, window_size)
fast_movsd(data, window_size)
find_chains(.mp)
find_discord(.mp, ...)
find_motif(.mp, ...)
fluss(.mp, num_segments, exclusion_zone = NULL)
fluss_cac(.mp, exclusion_zone = NULL)
fluss_extract(.mpac, num_segments, exclusion_zone = NULL)
fluss_score(gtruth, extracted, data_size)
get_data(.mp)
mass(data_fft, query_window, data_size, window_size, data_mean, data_sd, query_mean, query_sd)
mass_pre(data, data_size, query = NULL, query_size = NULL, window_size)
mstomp(data, window_size, exclusion_zone = 1/2, verbose = 2, must_dim = NULL, exc_dim = NULL)
mstomp_par(data, window_size, exclusion_zone = 1/2, verbose = 2, must_dim = NULL, exc_dim = NULL, n_workers = 2)
plot_arcs(pairs, alpha = NULL, quality = 30, lwd = 15, col = c("blue", "orange"), main = "Arc Plot", ylab, xlab = "Profile Index", ...)
salient_mds(.mp, data, bit_idx = 1)
salient_score(.mp, gtruth)
salient_subsequences(.mp, data, n_bits = 8, n_cand = 10, exclusion_zone = NULL, verbose = 2)
scrimp(..., window_size, exclusion_zone = 1/2, verbose = 2, s_size = Inf, pre_scrimp = 1/4)
sdts_predict(model, data, window_size)
sdts_score(pred, gtruth, beta = 1)
sdts_train(data, label, window_size, beta = 1, pat_max = Inf, parallel = TRUE, verbose = 2)
set_data(.mp, data)
simple_fast(..., window_size, exclusion_zone = 1/2, verbose = 2)
stamp(..., window_size, exclusion_zone = 1/2, verbose = 2, s_size = Inf)
stamp_par(..., window_size, exclusion_zone = 1/2, verbose = 2, s_size = Inf, n_workers = 2)
stomp(..., window_size, exclusion_zone = 1/2, verbose = 2)
stomp_par(..., window_size, exclusion_zone = 1/2, verbose = 2, n_workers = 2)
tsmp(..., window_size, exclusion_zone = 1/2, mode = c("stomp", "stamp", "simple", "mstomp", "scrimp", "valmod"), verbose = 2, n_workers = 1, s_size = Inf, must_dim = NULL, exc_dim = NULL, heap_size = 50, .keep_data = TRUE)
valmod(..., window_min, window_max, heap_size = 50, exclusion_zone = 1/2, lb = TRUE, verbose = 2)

## Own S3 methods

find_discord.MatrixProfile(.mp, data, n_discords = 1, n_neighbors = 3, radius = 3, exclusion_zone = NULL, ...)
find_motif.MatrixProfile(.mp, data, n_motifs = 3, n_neighbors = 10, radius = 3, exclusion_zone = NULL, ...)
find_motif.MultiMatrixProfile(.mp, data, n_motifs = 3, mode = c("guided", "unconstrained"), n_bit = 4, exclusion_zone = NULL, n_dim = NULL, ...)

## Foreign S3 methods

plot.ArcCount(x, data, type = c("data", "matrix"), exclusion_zone = NULL, edge_limit = NULL, threshold = stats::quantile(x$cac, 0.1), main = "Arcs Discover", xlab = "index", ylab, ...)
plot.Chain(x, data, type = c("data", "matrix"), main = "Chain Discover", xlab = "index", ylab, ...)
plot.Discord(x, data, type = c("data", "matrix"), ncol = 3, main = "Discord Discover", xlab = "index", ylab, ...)
plot.Fluss(x, data, type = c("data", "matrix"), main = "Fast Low-cost Unipotent Semantic Segmentation", xlab = "index", ylab, ...)
plot.MatrixProfile(x, ylab = "distance", xlab = "index", main = "Unidimensional Matrix Profile", ...)
plot.Motif(x, data, type = c("data", "matrix"), ncol = 3, main = "MOTIF Discover", xlab = "index", ylab, ...)
plot.MultiMatrixProfile(x, ylab = "distance", xlab = "index", main = "Multidimensional Matrix Profile", ...)
plot.MultiMotif(x, data, type = c("data", "matrix"), ncol = 3, main = "Multidimensional MOTIF Discover", xlab = "index", ylab, ...)
plot.Salient(x, data, main = "Salient Subsections", xlab = "index", ylab, ...)
plot.SimpleMatrixProfile(x, ylab = "distance", xlab = "index", main = "SiMPle Matrix Profile", ...)
plot.Valmod(x, ylab = "distance", xlab = "index", main = "Valmod Matrix Profile", ...)
print.ArcCount(x, ...)
print.Chain(x, ...)
print.Discord(x, ...)
print.Fluss(x, ...)
print.MatrixProfile(x, ...)
print.Motif(x, ...)
print.MultiMatrixProfile(x, ...)
print.MultiMotif(x, ...)
print.Salient(x, ...)
print.SimpleMatrixProfile(x, ...)
print.Valmod(x, ...)

## Reexported objects

::%>%
::%T>%
4 changes: 2 additions & 2 deletions CRAN-RELEASE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This package was submitted to CRAN on 2018-10-23.
Once it is accepted, delete this file and tag the release (commit 0e7131cff8).
This package was submitted to CRAN on 2019-02-24.
Once it is accepted, delete this file and tag the release (commit da04b9872c).
4 changes: 2 additions & 2 deletions 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.2
Version: 0.3.4.9000
Authors@R: c(
person("Francisco", "Bischoff", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "https://orcid.org/0000-0002-5301-8672")),
Expand All @@ -25,7 +25,7 @@ Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.0.9000
RoxygenNote: 6.1.1
NeedsCompilation: no
Suggests:
spelling,
Expand Down
9 changes: 9 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
# Generated by roxygen2: do not edit by hand

S3method(find_discord,MatrixProfile)
S3method(find_motif,MatrixProfile)
S3method(find_motif,MultiMatrixProfile)
S3method(plot,ArcCount)
S3method(plot,Chain)
S3method(plot,Discord)
S3method(plot,Fluss)
S3method(plot,MatrixProfile)
S3method(plot,Motif)
S3method(plot,MultiMatrixProfile)
S3method(plot,MultiMotif)
S3method(plot,Salient)
S3method(plot,SimpleMatrixProfile)
S3method(plot,Valmod)
S3method(print,ArcCount)
S3method(print,Chain)
S3method(print,Discord)
S3method(print,Fluss)
S3method(print,MatrixProfile)
S3method(print,Motif)
S3method(print,MultiMatrixProfile)
S3method(print,MultiMotif)
S3method(print,Salient)
S3method(print,SimpleMatrixProfile)
S3method(print,Valmod)
export("%>%")
export("%T>%")
export(as.arccount)
export(as.chain)
export(as.discord)
export(as.fluss)
export(as.matrixprofile)
export(as.motif)
export(as.multimatrixprofile)
export(as.multimotif)
export(as.salient)
export(as.valmod)
export(av_apply)
export(av_complexity)
export(av_hardlimit_artifact)
Expand All @@ -39,6 +46,7 @@ export(av_zerocrossing)
export(fast_movavg)
export(fast_movsd)
export(find_chains)
export(find_discord)
export(find_motif)
export(fluss)
export(fluss_cac)
Expand All @@ -64,5 +72,6 @@ export(stamp_par)
export(stomp)
export(stomp_par)
export(tsmp)
export(valmod)
importFrom(magrittr,"%>%")
importFrom(magrittr,"%T>%")
18 changes: 16 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
<!-- NEWS.md is generated from NEWS.Rmd. Please edit that file -->
tsmp 0.3.1.9000
===============
tsmp 0.3.4
==========

- Added `find_discord()` and its `print()` and `plot()` functions.
- Changed `plot()` for motifs to show where are the neighbors. Same
for discord.
- Added `valmod()` for Variable Length Motif Discovery.
- Changed `find_motif()` for compatibility with `valmod()`.

tsmp 0.3.3
==========

- Fixed `find_chains()` not returning the longest chain. Issue \#33

tsmp 0.3.2
==========

- Fixed Matrix Profile print, dimensions are now reported correctly.
- Fixed pipe imports. Issue \#22
Expand Down
12 changes: 11 additions & 1 deletion NEWS.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ knitr::opts_chunk$set(
)
```

# tsmp 0.3.1.9000
# tsmp 0.3.4
* Added `find_discord()` and its `print()` and `plot()` functions.
* Changed `plot()` for motifs to show where are the neighbors. Same for discord.
* Added `valmod()` for Variable Length Motif Discovery.
* Changed `find_motif()` for compatibility with `valmod()`.

# tsmp 0.3.3

* Fixed `find_chains()` not returning the longest chain. Issue #33

# tsmp 0.3.2

* Fixed Matrix Profile print, dimensions are now reported correctly.
* Fixed pipe imports. Issue #22
Expand Down
16 changes: 14 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
NEWS
================
Francisco Bischoff
\- 23 Oct 2018
\- 23 Feb 2019

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

# tsmp 0.3.1.9000
# tsmp 0.3.4

- Added `find_discord()` and its `print()` and `plot()` functions.
- Changed `plot()` for motifs to show where are the neighbors. Same
for discord.
- Added `valmod()` for Variable Length Motif Discovery.
- Changed `find_motif()` for compatibility with `valmod()`.

# tsmp 0.3.3

- Fixed `find_chains()` not returning the longest chain. Issue \#33

# tsmp 0.3.2

- Fixed Matrix Profile print, dimensions are now reported correctly.
- Fixed pipe imports. Issue \#22
Expand Down
30 changes: 22 additions & 8 deletions R/annotations.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
#' w <- 50
#' mp <- tsmp(data, window_size = w, verbose = 0)
#' av <- av_zerocrossing(mp, apply = TRUE)
#'
av_zerocrossing <- function(.mp, data, apply = FALSE) {
if ("Valmod" %in% class(.mp)) {
stop("Error: Function not implemented for objects of class `Valmod`.")
}

if (missing(data) && !is.null(.mp$data)) {
data <- .mp$data[[1]]
}
Expand Down Expand Up @@ -62,8 +65,11 @@ av_zerocrossing <- function(.mp, data, apply = FALSE) {
#' w <- 50
#' mp <- tsmp(data, window_size = w, verbose = 0)
#' av <- av_complexity(mp, apply = TRUE)
#'
av_complexity <- function(.mp, data, dilution_factor = 0, apply = FALSE) {
if ("Valmod" %in% class(.mp)) {
stop("Error: Function not implemented for objects of class `Valmod`.")
}

if (missing(data) && !is.null(.mp$data)) {
data <- .mp$data[[1]]
}
Expand Down Expand Up @@ -113,8 +119,11 @@ av_complexity <- function(.mp, data, dilution_factor = 0, apply = FALSE) {
#' w <- 50
#' mp <- tsmp(data, window_size = w, verbose = 0)
#' av <- av_motion_artifact(mp, apply = TRUE)
#'
av_motion_artifact <- function(.mp, data, apply = FALSE) {
if ("Valmod" %in% class(.mp)) {
stop("Error: Function not implemented for objects of class `Valmod`.")
}

if (missing(data) && !is.null(.mp$data)) {
data <- .mp$data[[1]]
}
Expand Down Expand Up @@ -171,8 +180,11 @@ av_motion_artifact <- function(.mp, data, apply = FALSE) {
#' w <- 50
#' mp <- tsmp(data, window_size = w, verbose = 0)
#' av <- av_stop_word(mp, stop_word_loc = 150, apply = TRUE)
#'
av_stop_word <- function(.mp, data, stop_word_loc, exclusion_zone = NULL, threshold = 0.1, apply = FALSE) {
if ("Valmod" %in% class(.mp)) {
stop("Error: Function not implemented for objects of class `Valmod`.")
}

if (missing(data) && !is.null(.mp$data)) {
data <- .mp$data[[1]]
}
Expand Down Expand Up @@ -234,8 +246,11 @@ av_stop_word <- function(.mp, data, stop_word_loc, exclusion_zone = NULL, thresh
#' w <- 50
#' mp <- tsmp(data, window_size = w, verbose = 0)
#' av <- av_hardlimit_artifact(mp, apply = TRUE)
#'
av_hardlimit_artifact <- function(.mp, data, apply = FALSE) {
if ("Valmod" %in% class(.mp)) {
stop("Error: Function not implemented for objects of class `Valmod`.")
}

if (missing(data) && !is.null(.mp$data)) {
data <- .mp$data[[1]]
}
Expand Down Expand Up @@ -287,13 +302,12 @@ av_hardlimit_artifact <- function(.mp, data, apply = FALSE) {
#' mp <- tsmp(data, window_size = w, verbose = 0)
#' mp <- av_complexity(mp)
#' av <- av_apply(mp)

av_apply <- function(.mp) {
if (!any(class(.mp) %in% "MatrixProfile")) {
if (!("MatrixProfile" %in% class(.mp))) {
stop("Error: First argument must be an object of class `MatrixProfile`.")
}

if (!any(class(.mp) %in% "AnnotationVector")) {
if (!("AnnotationVector" %in% class(.mp))) {
stop("Error: First argument must be an object of class `AnnotationVector`.")
}

Expand Down
13 changes: 9 additions & 4 deletions R/find-chains.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
#' @examples
#' w <- 50
#' data <- mp_gait_data
#' mp <- tsmp(data, window_size = w, exclusion_zone = 1/4, verbose = 0)
#' mp <- tsmp(data, window_size = w, exclusion_zone = 1 / 4, verbose = 0)
#' mp <- find_chains(mp)
#'
find_chains <- function(.mp) {
if (!any(class(.mp) %in% "MatrixProfile")) {
if (!("MatrixProfile" %in% class(.mp))) {
stop("Error: First argument must be an object of class `MatrixProfile`.")
}

if ("Valmod" %in% class(.mp)) {
stop("Error: Function not implemented for objects of class `Valmod`.")
}

size <- length(.mp$rpi)
chain_length <- rep(1, size)
chain_set <- list()
Expand Down Expand Up @@ -52,7 +55,9 @@ find_chains <- function(.mp) {
mean <- Inf
for (i in seq_len(length(chain_set))) {
if (length(chain_set[[i]]) == l) {
n <- mean(.mp$rmp[chain_set[[i]]])
vals <- .mp$rmp[chain_set[[i]]]
vals <- vals[!is.infinite(vals)]
n <- mean(vals)
if (n < mean) {
mean <- n
best_chain <- chain_set[[i]]
Expand Down
Loading

0 comments on commit 664c20e

Please sign in to comment.