Last updated: 2022-10-05
Checks: 7 0
Knit directory:
false.alarm/docs/
This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20201020)
was run prior to running the code in the R Markdown file.
Setting a seed ensures that any results that rely on randomness, e.g.
subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version b79f104. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the
analysis have been committed to Git prior to generating the results (you can
use wflow_publish
or wflow_git_commit
). workflowr only
checks the R Markdown file, but you know if there are other scripts or data
files that it depends on. Below is the status of the Git repository when the
results were generated:
Ignored files:
Ignored: .Renviron
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: .devcontainer/exts/
Ignored: .docker/
Ignored: .github/ISSUE_TEMPLATE/
Ignored: .httr-oauth
Ignored: R/RcppExports.R
Ignored: _regime_change/meta/process
Ignored: _regime_change/meta/progress
Ignored: _regime_change/objects/
Ignored: _regime_change/user/
Ignored: _regime_change2/meta/process
Ignored: _regime_change2/meta/progress
Ignored: _regime_change2/objects/
Ignored: _regime_change2/user/
Ignored: _regime_change3/meta/process
Ignored: _regime_change3/meta/progress
Ignored: _regime_change3/objects/
Ignored: _regime_change3/user/
Ignored: _regime_optimize/meta/meta2
Ignored: _regime_optimize/meta/process
Ignored: _regime_optimize/meta/progress
Ignored: _regime_optimize/objects/
Ignored: _regime_optimize/user/
Ignored: _targets/meta/process
Ignored: _targets/meta/progress
Ignored: _targets/objects/
Ignored: _targets/user/
Ignored: analysis/shiny/rsconnect/
Ignored: analysis/shiny_land/rsconnect/
Ignored: dev/
Ignored: inst/extdata/
Ignored: papers/aime2021/aime2021.md
Ignored: papers/epia2022/epia2022.md
Ignored: presentations/MEDCIDS21/MEDCIDS21-10min_files/
Ignored: presentations/MEDCIDS21/MEDCIDS21_files/
Ignored: presentations/Report/Midterm-Report_cache/
Ignored: presentations/Report/Midterm-Report_files/
Ignored: protocol/SecondReport_cache/
Ignored: protocol/SecondReport_files/
Ignored: protocol/_files/
Ignored: renv/python/
Ignored: renv/staging/
Ignored: src/RcppExports.cpp
Ignored: src/RcppExports.o
Ignored: src/contrast.o
Ignored: src/false.alarm.so
Ignored: src/fft.o
Ignored: src/mass.o
Ignored: src/math.o
Ignored: src/mpx.o
Ignored: src/scrimp.o
Ignored: src/stamp.o
Ignored: src/stomp.o
Ignored: src/windowfunc.o
Ignored: thesis/Rplots.pdf
Ignored: thesis/_bookdown_files/
Ignored: tmp/
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made
to the R Markdown (analysis/blog-202110.Rmd
) and HTML (docs/blog-202110.html
)
files. If you’ve configured a remote Git repository (see
?wflow_git_remote
), click on the hyperlinks in the table below to
view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
html | dbbd1d6 | Francisco Bischoff | 2022-08-22 | Squashed commit of the following: |
html | de21180 | Francisco Bischoff | 2022-08-21 | Squashed commit of the following: |
html | 5943a09 | Francisco Bischoff | 2022-07-21 | Build site. |
html | 3328477 | Francisco Bischoff | 2022-07-21 | Build site. |
Rmd | f86f334 | Francisco Bischoff | 2022-07-19 | new article |
Rmd | 03d1e68 | Francisco Bischoff | 2022-07-19 | Squashed commit of the following: |
html | 5927668 | Francisco Bischoff | 2022-04-17 | Build site. |
Rmd | ba0c9e1 | Francisco Bischoff | 2022-04-17 | refactor blog |
While implementing the streaming-like pipeline, some declarations must be made. In 2017, the FLUSS (Fast Low-cost Unipotent Semantic Segmentation) and the FLOSS (Fast Low-cost Online Semantic Segmentation) algorithms were introduced by Gharghabi et al.1. In 2018, the same group published their findings using multi-dimensional time series2 using the same algorithms.
Claims about the algorithm:
Briefly describing the regime detection algorithm, which can be explored in the original paper2, it is based on the assumption that between two regimes, the most similar shape (its nearest neighbor) is located on “the same side”. This information is obtained from the Matrix Profile computation. More precisely, using only the Profile Index.
Before talking about the Matrix Profile computation, some findings deserve to be mentioned:
In chapter 3.5 in the original paper, the authors of FLOSS wisely introduce the temporal constraint. Nevertheless, some details are not mentioned. 1) As this algorithm only needs the Profile Index, should we use the already computed Indexes or recompute the Matrix Profile using this constraint (i.e., the constraint is on the Profile Index or the FLOSS algorithm?). That is not an issue about the algorithm but a choice we need to make beforehand. One option is to apply the constraint on the Profile Index, and we need to have this parameter set from the start. The second option is to have the FLOSS algorithm not account for the indexes beyond the constraint, keeping the original Profile Index. 2) The authors declare the correction curve typically used on FLUSS and FLOSS as “simply a uniform distribution”, but this is not an accurate statement. Empirically, there is a helpful pattern to know about the distribution when using temporal constraints (at least from the start, in the Matrix Profile stage). At first glance, we see that the distribution resembles the skewed distribution used in FLOSS but is shorter, while the \(constraint \ge MatrixProfileSize/2\). For lower constraints, the maximum value of this distribution is equal to \(MatrixProfileSize/2\) between the indexes \(constraint\) to the index \(MatrixProfileSize - (constraint \times 0.9)\). This is shown in Fig. 1. That is important because the output of the FLOSS algorithm should be normalized and constrained between 0 and 1, which allows us to compare different trials using different parameters in the process. Finally, the last datapoints are not irrelevant, opposed to what was stated by the authors, since an Online algorithm needs to return an answer as soon as the application domain requires. That is very much relevant to this work’s field, as, for example, for asystole detection, we have a window of 4 seconds to fire the alarm. If the time constraint is 10 seconds, this would mean (by the original article) that the last 10 seconds of the incoming data would not be sufficient to detect the regime change.
As for the first point mentioned above, it seems more appropriate to set the temporal constraint in the Matrix Profile algorithm, and indeed this is what the original paper did. That reduces the computation time of the online Matrix Profile, and any post-processing done afterward will inherit this constraint. The distribution for correcting the FLOSS algorithm is also simpler. On the other hand, it is possible to apply the time constraint in the FLOSS algorithm, leaving the online Matrix Profile in its original form. See Fig. 2. The theoretical distribution changes significantly according to the constraint value. The upside of this approach, at least during the prospective phase, is to allow us to decide the time constraint value later in the pipeline, avoiding the recomputation of the Matrix Profile. The results on detecting regime changes are very similar to the first approach. See Fig. 3.
Concerning the second point mentioned above, the solution for evaluating the effect of using time constraints in this work’s setting was to generate the ideal distribution using the constrained parameters beforehand. That gives us enough data to evaluate a regime change accurately utilizing a minimum of \(2 \times WindowSize\) datapoints. The best index is still to be determined, and current tests are using 3 seconds limit.
Version | Author | Date |
---|---|---|
ba0c9e1 | Francisco Bischoff | 2022-04-17 |
Version | Author | Date |
---|---|---|
ba0c9e1 | Francisco Bischoff | 2022-04-17 |
Version | Author | Date |
---|---|---|
ba0c9e1 | Francisco Bischoff | 2022-04-17 |
Since the first Matrix Profile computation algorithm, the STAMP4, several improvements on the algorithm were made5,6. Still, the ability to keep a growing Matrix Profile (i.e., Online) relies on the STAMP algorithm. If the problem allows collecting several data points (chunks), STOMP5 can speed up the computation. Curiously, the main bottleneck of all these algorithms is the FFT (Fast Fourier Transform) algorithm that is the core of the MASS algorithm published by Mueen et al.7 in 2010 and later in 2015, having its code released on Professor Mueen’s webpage8. The FFT libraries available are highly optimized and CPU (or GPU) dependent what makes it at the same time fast but brittle and not suitable for MCU’s (Microcontroller Unit), for example. More interestingly yet, is the fact that several published works using Matrix Profile, MPdist9, for instance, uses an unpublished algorithm called ‘MPX’ that computes the Matrix Profile using cross-correlation methods ending up faster and is easily portable.
This work contributes to extending the MPX algorithm to allow the Online computation of the Matrix Profile. More precisely, we are interested in the Right Matrix Profile, whose updated indexes refer only to the last incoming datapoint since we are looking for future regime changes, not backward. This one-directional algorithm is already described in the FLOSS paper2.
Another contribution of this work is an unexplored constraint that we could apply on building the Matrix Profile that we will call Similarity Threshold (ST). The original work outputs the similarity values in Euclidean Distance (ED) values, while MPX naturally outputs the values in Pearson’s correlation (CC) coefficients. Both ED and CC are interchangeable using the equation (1). However, we may argue that it is easier to compare values that do not depend on the \(WindowSize\) during an exploratory phase. MPX happens to naturally return values in CC, saving a few more computation time.
\[ CC = 1 - \frac{ED}{(2 \times WindowSize)} \tag{1} \]
The ST is an interesting factor that we can use, especially when detecting pattern changes during time. The FLUSS/FLOSS algorithms rely on counting references between indexes in the time series. ST can help remove “noise” from these references since only similar patterns above a certain threshold are referenced, and changes have more impact on these counts. More information and visual content on ST will be provided later. The best ST threshold is still to be determined.
─ Session info ───────────────────────────────────────────────────────────────
setting value
version R version 4.2.1 (2022-06-23)
os Ubuntu 20.04.5 LTS
system x86_64, linux-gnu
ui X11
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz Europe/Lisbon
date 2022-10-05
pandoc 2.17.0.1 @ /usr/bin/ (via rmarkdown)
─ Packages ───────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
askpass 1.1 2019-01-13 [1] CRAN (R 4.2.0)
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.2.0)
backports 1.4.1 2021-12-13 [1] CRAN (R 4.2.0)
base64url 1.4 2018-05-14 [1] CRAN (R 4.2.0)
bookdown 0.29.2 2022-09-26 [1] Github (rstudio/bookdown@dfe92a2)
bslib 0.4.0 2022-07-16 [1] CRAN (R 4.2.1)
cachem 1.0.6 2021-08-19 [1] CRAN (R 4.2.0)
callr 3.7.2 2022-08-22 [1] CRAN (R 4.2.1)
cli 3.4.1 2022-09-23 [1] CRAN (R 4.2.1)
codetools 0.2-18 2020-11-04 [2] CRAN (R 4.2.0)
colorspace 2.0-3 2022-02-21 [1] CRAN (R 4.2.0)
conflicted 1.1.0 2021-11-26 [1] CRAN (R 4.2.0)
crayon 1.5.1 2022-03-26 [1] CRAN (R 4.2.0)
credentials 1.3.2 2021-11-29 [1] CRAN (R 4.2.0)
data.table 1.14.2 2021-09-27 [1] CRAN (R 4.2.0)
DBI 1.1.3 2022-06-18 [1] CRAN (R 4.2.0)
debugme 1.1.0 2017-10-22 [1] CRAN (R 4.2.0)
devtools 2.4.4 2022-07-20 [1] CRAN (R 4.2.1)
digest 0.6.29 2021-12-01 [1] CRAN (R 4.2.0)
dplyr * 1.0.10 2022-09-01 [1] CRAN (R 4.2.1)
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.2.0)
evaluate 0.16 2022-08-09 [1] CRAN (R 4.2.1)
fansi 1.0.3 2022-03-24 [1] CRAN (R 4.2.0)
farver 2.1.1 2022-07-06 [1] CRAN (R 4.2.0)
fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.2.0)
fs 1.5.2 2021-12-08 [1] CRAN (R 4.2.0)
generics 0.1.3 2022-07-05 [1] CRAN (R 4.2.0)
gert 1.9.0 2022-09-15 [1] CRAN (R 4.2.1)
getPass 0.2-2 2017-07-21 [1] CRAN (R 4.2.0)
ggplot2 * 3.3.6 2022-05-03 [1] CRAN (R 4.2.0)
git2r 0.30.1.9000 2022-04-29 [1] Github (ropensci/git2r@80ba185)
gittargets * 0.0.5.9000 2022-09-26 [1] Github (wlandau/gittargets@a50dd58)
glue * 1.6.2 2022-02-24 [1] CRAN (R 4.2.0)
gridExtra 2.3 2017-09-09 [1] CRAN (R 4.2.0)
gtable 0.3.1 2022-09-01 [1] CRAN (R 4.2.1)
here * 1.0.1 2020-12-13 [1] CRAN (R 4.2.0)
highr 0.9 2021-04-16 [1] CRAN (R 4.2.0)
htmltools 0.5.3 2022-07-18 [1] CRAN (R 4.2.1)
htmlwidgets 1.5.4 2021-09-08 [1] CRAN (R 4.2.0)
httpuv 1.6.6 2022-09-08 [1] CRAN (R 4.2.1)
httr 1.4.4 2022-08-17 [1] CRAN (R 4.2.1)
igraph 1.3.5 2022-09-22 [1] CRAN (R 4.2.1)
jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.2.0)
jsonlite 1.8.0 2022-02-22 [1] CRAN (R 4.2.0)
kableExtra * 1.3.4 2021-02-20 [1] CRAN (R 4.2.0)
knitr 1.40 2022-08-24 [1] CRAN (R 4.2.1)
labeling 0.4.2 2020-10-20 [1] CRAN (R 4.2.0)
later 1.3.0 2021-08-18 [1] CRAN (R 4.2.0)
lazyeval 0.2.2 2019-03-15 [1] CRAN (R 4.2.0)
lifecycle 1.0.2 2022-09-09 [1] CRAN (R 4.2.1)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0)
memoise 2.0.1 2021-11-26 [1] CRAN (R 4.2.0)
mime 0.12 2021-09-28 [1] CRAN (R 4.2.0)
miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.2.0)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.2.0)
openssl 2.0.3 2022-09-14 [1] CRAN (R 4.2.1)
pillar 1.8.1 2022-08-19 [1] CRAN (R 4.2.1)
pkgbuild 1.3.1 2021-12-20 [1] CRAN (R 4.2.0)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.0)
pkgload 1.3.0 2022-06-27 [1] CRAN (R 4.2.0)
plotly * 4.10.0 2021-10-09 [1] CRAN (R 4.2.0)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.2.0)
processx 3.7.0 2022-07-07 [1] CRAN (R 4.2.1)
profvis 0.3.7 2020-11-02 [1] CRAN (R 4.2.1)
promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.2.0)
ps 1.7.1 2022-06-18 [1] CRAN (R 4.2.0)
purrr 0.3.4 2020-04-17 [1] CRAN (R 4.2.0)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.0)
Rcpp 1.0.9 2022-07-08 [1] CRAN (R 4.2.1)
remotes 2.4.2 2021-11-30 [1] CRAN (R 4.2.0)
renv 0.15.5 2022-05-26 [1] CRAN (R 4.2.0)
rlang 1.0.6 2022-09-24 [1] CRAN (R 4.2.1)
rmarkdown 2.16.1 2022-09-26 [1] Github (rstudio/rmarkdown@9577707)
rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.2.0)
rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.1)
rvest 1.0.3 2022-08-19 [1] CRAN (R 4.2.1)
sass 0.4.2 2022-07-16 [1] CRAN (R 4.2.1)
scales 1.2.1 2022-08-20 [1] CRAN (R 4.2.1)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0)
shiny 1.7.2 2022-07-19 [1] CRAN (R 4.2.1)
stringi 1.7.8 2022-07-11 [1] CRAN (R 4.2.1)
stringr 1.4.1 2022-08-20 [1] CRAN (R 4.2.1)
svglite 2.1.0.9000 2022-09-26 [1] Github (r-lib/svglite@8f30fc6)
sys 3.4 2020-07-23 [1] CRAN (R 4.2.0)
systemfonts 1.0.4 2022-02-11 [1] CRAN (R 4.2.0)
tarchetypes * 0.7.1 2022-09-07 [1] CRAN (R 4.2.1)
targets * 0.13.4 2022-09-15 [1] CRAN (R 4.2.1)
tibble * 3.1.8 2022-07-22 [1] CRAN (R 4.2.1)
tidyr 1.2.1 2022-09-08 [1] CRAN (R 4.2.1)
tidyselect 1.1.2 2022-02-21 [1] CRAN (R 4.2.0)
urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.2.1)
usethis 2.1.6.9000 2022-10-03 [1] Github (r-lib/usethis@8ecb7ab)
utf8 1.2.2 2021-07-24 [1] CRAN (R 4.2.0)
uuid 1.1-0 2022-04-19 [1] CRAN (R 4.2.0)
vctrs 0.4.1 2022-04-13 [1] CRAN (R 4.2.0)
viridisLite 0.4.1 2022-08-22 [1] CRAN (R 4.2.1)
webshot 0.5.3 2022-04-14 [1] CRAN (R 4.2.0)
whisker 0.4 2019-08-28 [1] CRAN (R 4.2.0)
withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.0)
workflowr * 1.7.0 2021-12-21 [1] CRAN (R 4.2.0)
xfun 0.33 2022-09-12 [1] CRAN (R 4.2.1)
xml2 1.3.3 2021-11-30 [1] CRAN (R 4.2.0)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.2.0)
yaml 2.3.5 2022-02-21 [1] CRAN (R 4.2.0)
[1] /workspace/.cache/R/renv/proj_libs/false.alarm-d6f1a0d1/R-4.2/x86_64-pc-linux-gnu
[2] /usr/lib/R/library
──────────────────────────────────────────────────────────────────────────────