-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
94 changed files
with
2,358 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ | |
^README-.*\.png$ | ||
^\.httr-oauth$ | ||
^make\.R$ | ||
^CONDUCT\.md$ | ||
^CODE_OF_CONDUCT\.md$ | ||
^\.github/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#' Find Time Series Chains | ||
#' | ||
#' Time Series Chains is a new primitive for time series data mining. | ||
#' | ||
#' @param matrices a result from STAMP or STOMP algorithms | ||
#' | ||
#' @return Returns `chains`, a `list` of chains founded with more than 2 patterns and `best` | ||
#' with the best one. | ||
#' @export | ||
#' @references 1. Zhu Y, Imamura M, Nikovski D, Keogh E. Introducing time series chains: a new | ||
#' primitive for time series data mining. Knowl Inf Syst. 2018 Jun 2;1–27. | ||
#' @references Website: <https://sites.google.com/site/timeserieschain/> | ||
#' @examples | ||
#' w <- 50 | ||
#' data <- gait_data | ||
#' mp <- stamp(data, window.size = w, exclusion.zone = 1/4, verbose = 0) | ||
#' find.chains(mp) | ||
#' | ||
find.chains <- function(matrices) { | ||
size <- length(matrices$rpi) | ||
chain.length <- rep(1, size) | ||
chain.set <- list() | ||
|
||
k <- 1 | ||
|
||
for (i in 1:size) { | ||
if (chain.length[i] == 1) { | ||
j <- i | ||
chain <- j | ||
|
||
while (matrices$rpi[j] > 0 && matrices$lpi[matrices$rpi[j]] == j) { | ||
j <- matrices$rpi[j] | ||
chain.length[j] <- -1 | ||
chain.length[i] <- chain.length[i] + 1 | ||
chain <- c(chain, j) | ||
} | ||
|
||
if (length(chain) > 2) { | ||
chain.set[[k]] <- chain | ||
k <- k + 1 | ||
} | ||
} | ||
} | ||
|
||
l <- max(chain.length) | ||
|
||
best.chain <- NULL | ||
mean <- Inf | ||
for (i in 1:length(chain.set)) { | ||
if (length(chain.set[[i]]) == l) { | ||
n <- mean(matrices$rmp[chain.set[[i]]]) | ||
if (n < mean) { | ||
mean <- n | ||
best.chain <- chain.set[[i]] | ||
} | ||
} | ||
} | ||
|
||
return(list(chains = chain.set, best = best.chain)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#' Original data used in the Time Series Chain demo | ||
#' | ||
#' @docType data | ||
#' @format A `matrix` with 904 rows and 1 column with the Y data from an accelerometer | ||
#' @source \url{https://sites.google.com/site/timeserieschain/} | ||
#' | ||
#' @references 1. Zhu Y, Imamura M, Nikovski D, Keogh E. Introducing time series chains: a new primitive for time series data mining. Knowl Inf Syst. 2018 Jun 2;1–27. | ||
#' @keywords datasets | ||
"gait_data" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.