diff --git a/DESCRIPTION b/DESCRIPTION index 60b69f0..1c4f48f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,15 +1,15 @@ Package: EventDetectR -Version: 0.3.4 +Version: 0.3.6 Title: Event Detection Framework Description: Detect events in time-series data. Combines multiple well-known R packages like 'forecast' and 'neuralnet' to deliver an easily configurable tool for multivariate event detection. Authors@R: c( person("Margarita", "Rebolledo", email="margarita.rebolledo@th-koeln.de", role=c("aut")), - person("Sowmya", "Chandrasekaran", email="sowzz.17@gmail.com", role=c("aut")), - person("Frederik", "Rehbach", email="frederik.re@gmail.com", role=c("aut", "cre")), + person("Sowmya", "Chandrasekaran", email="sowzz.17@gmail.com", role=c("aut", "cre")), + person("Frederik", "Rehbach", email="frederik.re@gmail.com", role=c("aut")), person("Steffen", "Moritz", email="steffen.moritz10@gmail.com", role=c("aut"), comment = c(ORCID = "0000-0002-0085-1804")) ) -Maintainer: Sowmya Chandrasekaran +Encoding: UTF-8 LazyData: yes Type: Package ByteCompile: TRUE @@ -18,7 +18,8 @@ URL: https://github.com/frehbach/EventDetectR Repository: CRAN Depends: R (>= 3.1.0) -Imports: imputeTS, forecast, ggplot2, gridExtra, neuralnet +Imports: imputeTS, forecast, ggplot2, gridExtra, neuralnet, Rdpack +RdMacros: Rdpack Suggests: testthat, utils, caret, e1071 License: GPL-3 -RoxygenNote: 6.1.1 +RoxygenNote: 7.1.1 diff --git a/NAMESPACE b/NAMESPACE index b38251a..5783f4b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,3 +16,4 @@ import(imputeTS) import(neuralnet) import(stats) import(utils) +importFrom(Rdpack,reprompt) diff --git a/R/EventDetectR-package.R b/R/EventDetectR-package.R index e9e4d9e..26085f7 100644 --- a/R/EventDetectR-package.R +++ b/R/EventDetectR-package.R @@ -1,14 +1,16 @@ #' @title EventDetectR-package description #' @description -#' The EventDetectR package is a modular event detection system +#' Detect events/ anomalies in time-series data. + #' #' @details The EventDetectR package enables detection of events/ anomalies in multivariate time-series data. It combines multiple well-known R packages like 'forecast, 'neuralnet' to deliver an easily configurable tool for event detection. #' #' @name EventDetectR-package -#' -#' #' @docType package #' @import stats #' @import utils +#' @importFrom Rdpack reprompt +#' @references +#' \insertRef{Chan20a}{EventDetectR}\cr if(getRversion() >= "2.15.1") utils::globalVariables(c("x","y")) NULL diff --git a/R/detectEvents.R b/R/detectEvents.R index 524c503..44ef714 100644 --- a/R/detectEvents.R +++ b/R/detectEvents.R @@ -138,7 +138,7 @@ detectEvents <- function(x, }else{ modelingData <- x[1:(index + windowSize),,drop=FALSE] eventPositions <- which(edModel$eventHistory) -# Added by Sowmya to check if eventPositions exists +# Added to check if eventPositions exists if(length(eventPositions>0)) { modelingData <- modelingData[-eventPositions, , drop = FALSE] diff --git a/R/getDefaultControlLists.R b/R/getDefaultControlLists.R index 5650540..0665e2c 100644 --- a/R/getDefaultControlLists.R +++ b/R/getDefaultControlLists.R @@ -41,6 +41,6 @@ getDefaultPostControl <- function() { defaultControlList <- list( nStandardDeviationseventThreshold = 2, eventThreshold = .7, - bedWindowSize = 30 + bedWindowSize = 10 ) } diff --git a/R/model_NeuralNetwork.R b/R/model_NeuralNetwork.R index 36fd94a..c84385c 100644 --- a/R/model_NeuralNetwork.R +++ b/R/model_NeuralNetwork.R @@ -2,7 +2,7 @@ #' Fitting Neuralnet Models #' @details Multivariate Neuralnetwork model is formulated for each of the parameter using its own lagged values and rest of all parameters involved. For instance, considering 3 parameters 'p1', 'p2', 'p3', the value of 'p1' at time step 'i' is calclated as \cr #' \code{p1[i] = p2[i] + p3[i] + p1[i-1]} \cr -#' +#' It is recommended to activate the normalization of the data. #' @param x data #' @param control control list with settings #' @return fitted multivariate neural network model diff --git a/README.md b/README.md index 1eb28ce..6d5746a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,9 @@ require(devtools) install_github("frehbach/EventDetectR") ``` -Soon the package will also be available on CRAN. +The package is available on CRAN and can be installed: + +install.packages('EventDetectR') ## Usage The main function of the EventDetectR package is: @@ -69,7 +71,7 @@ getDefaultModelControl() getDefaultPostControl() ``` -The event classification itself is shown in the graph below. #TODO make this graph look nice +The event classification itself is shown in the graph below. ![Alt text](doc/Ver2_windowimage.png?raw=true "detectEvents.R") @@ -97,7 +99,7 @@ Since it was not specified on the function call the event duration defaults to 1 ------------- ## Graphical User Interface -A graphical user interface (GUI) for the EventDetectR package is currently in development. +A graphical user interface (GUI) for the EventDetectR package is also available. Check out the most recent status at: [EventDetectGUI](https://github.com/frehbach/EventDetectGUI) ------------- diff --git a/inst/CITATION b/inst/CITATION index b39a147..534ba9c 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -1,11 +1,13 @@ -year <- sub("-.*", "", meta$Date) -vers <- paste("R package version", meta$Version) +year <- 2019 +vers <- paste("R package version", year) citHeader("To cite the EventDetectR package, use:") bibentry(bibtype = "Manual", title = "EventDetectR", - author = personList(as.person("Steffen Moritz"), as.person("Frederik Rehbach")), + author = personList(as.person("Sowmya Chandrasekaran"),as.person("Steffen Moritz"), as.person("Margarita Rebolledo"),as.person("Frederik Rehbach")), year = year, note = vers, + organization = "Institute for Data Science, Engineering, and Analytics, Technische Hochschule Koeln", + address = "Steinmüllerallee 1, 51643 Gummersbach", url = "https://CRAN.R-project.org/package=EventDetectR") diff --git a/inst/REFERENCES.bib b/inst/REFERENCES.bib new file mode 100644 index 0000000..4038ad1 --- /dev/null +++ b/inst/REFERENCES.bib @@ -0,0 +1,9 @@ +@techreport{Chan20a, + author = {Sowmya Chandrasekaran and Margarita Rebolledo and Thomas Bartz-Beielstein}, + title = {EventDetectR – An Open-Source Event Detection System}, + url = {https://nbn-resolving.org/urn:nbn:de:hbz:832-cos4-9232}, + abstract = {EventDetectR: An efficient Event Detection System (EDS) capable of detecting unexpected water quality conditions. This approach uses multiple algorithms to model the relationship between various multivariate water quality signals. Then the residuals of the models were utilized in constructing the event detection algorithm, which provides a continuous measure of the probability of an event at every time step. The proposed framework was tested for water contamination events with industrial data from automated water quality sensors. The results showed that the framework is reliable with better performance and is highly suitable for event detection.}, + language = {en}, + institution={Institute for Data Science, Engineering, and Analytics, TH K\"oln, Steinmüllerallee 1, 51643 Gummersbach, Germany}, + year={2020} +} diff --git a/man/EventDetectR-package.Rd b/man/EventDetectR-package.Rd index 1a1277d..1c3ab0f 100644 --- a/man/EventDetectR-package.Rd +++ b/man/EventDetectR-package.Rd @@ -5,8 +5,11 @@ \alias{EventDetectR-package} \title{EventDetectR-package description} \description{ -The EventDetectR package is a modular event detection system +Detect events/ anomalies in time-series data. } \details{ The EventDetectR package enables detection of events/ anomalies in multivariate time-series data. It combines multiple well-known R packages like 'forecast, 'neuralnet' to deliver an easily configurable tool for event detection. } +\references{ +\insertRef{Chan20a}{EventDetectR}\cr +} diff --git a/man/buildEDModel.Rd b/man/buildEDModel.Rd index dd5e557..509d2c7 100644 --- a/man/buildEDModel.Rd +++ b/man/buildEDModel.Rd @@ -4,12 +4,18 @@ \alias{buildEDModel} \title{build Event Detection Model} \usage{ -buildEDModel(x, dataPrepators = "ImputeTSInterpolation", - dataPreparationControl = list(), buildModelAlgo = "ForecastETS", +buildEDModel( + x, + dataPrepators = "ImputeTSInterpolation", + dataPreparationControl = list(), + buildModelAlgo = "ForecastETS", buildForecastModelControl = list(), - buildNeuralNetModelControl = list(), postProcessors = "bedAlgo", - postProcessorControl = list(), ignoreVarianceWarning = FALSE, - oldModel = NULL) + buildNeuralNetModelControl = list(), + postProcessors = "bedAlgo", + postProcessorControl = list(), + ignoreVarianceWarning = FALSE, + oldModel = NULL +) } \arguments{ \item{x}{data.frame containing initial data on which the model will be fitted. diff --git a/man/detectEvents.Rd b/man/detectEvents.Rd index d3e4389..2fd281f 100644 --- a/man/detectEvents.Rd +++ b/man/detectEvents.Rd @@ -4,12 +4,20 @@ \alias{detectEvents} \title{detectEvents in a given data.frame} \usage{ -detectEvents(x, windowSize = 100, nIterationsRefit = 1, - verbosityLevel = 0, dataPrepators = "ImputeTSInterpolation", - dataPreparationControl = list(), buildModelAlgo = "ForecastETS", +detectEvents( + x, + windowSize = 100, + nIterationsRefit = 1, + verbosityLevel = 0, + dataPrepators = "ImputeTSInterpolation", + dataPreparationControl = list(), + buildModelAlgo = "ForecastETS", buildForecastModelControl = list(), - buildNeuralNetModelControl = list(), postProcessors = "bedAlgo", - postProcessorControl = list(), ignoreVarianceWarning = TRUE) + buildNeuralNetModelControl = list(), + postProcessors = "bedAlgo", + postProcessorControl = list(), + ignoreVarianceWarning = TRUE +) } \arguments{ \item{x}{data.frame, data which shall be classified as event or not} diff --git a/man/model_NeuralNetwork.Rd b/man/model_NeuralNetwork.Rd index c72a105..bc70a59 100644 --- a/man/model_NeuralNetwork.Rd +++ b/man/model_NeuralNetwork.Rd @@ -20,5 +20,6 @@ Fitting Neuralnet Models \details{ Multivariate Neuralnetwork model is formulated for each of the parameter using its own lagged values and rest of all parameters involved. For instance, considering 3 parameters 'p1', 'p2', 'p3', the value of 'p1' at time step 'i' is calclated as \cr \code{p1[i] = p2[i] + p3[i] + p1[i-1]} \cr +It is recommended to activate the normalization of the data. } \keyword{internal} diff --git a/man/plot.edObject.Rd b/man/plot.edObject.Rd index 9ff399d..21215f0 100644 --- a/man/plot.edObject.Rd +++ b/man/plot.edObject.Rd @@ -4,8 +4,7 @@ \alias{plot.edObject} \title{Plot an Event Detection Object} \usage{ -\method{plot}{edObject}(x, varsToPlot = names(edObject$classification), - ...) +\method{plot}{edObject}(x, varsToPlot = names(edObject$classification), ...) } \arguments{ \item{x}{edObject} diff --git a/man/simulateEvents.Rd b/man/simulateEvents.Rd index 497590d..836ab0d 100644 --- a/man/simulateEvents.Rd +++ b/man/simulateEvents.Rd @@ -4,8 +4,15 @@ \alias{simulateEvents} \title{Imposes simulated events on the top of the data} \usage{ -simulateEvents(Data, Params, Event_type, Event_strength = NULL, - Start_index = NULL, Event_duration = NULL, Percentage = NULL) +simulateEvents( + Data, + Params, + Event_type, + Event_strength = NULL, + Start_index = NULL, + Event_duration = NULL, + Percentage = NULL +) } \arguments{ \item{Data}{Data frame or matrix containing the data to which the events will be introduced} diff --git a/tests/testthat/Rplots.pdf b/tests/testthat/Rplots.pdf index b21a1f7..9f9ed9f 100644 Binary files a/tests/testthat/Rplots.pdf and b/tests/testthat/Rplots.pdf differ diff --git a/tests/testthat/test-eventClassification.R b/tests/testthat/test-eventClassification.R index c67fa05..8db9afd 100644 --- a/tests/testthat/test-eventClassification.R +++ b/tests/testthat/test-eventClassification.R @@ -88,15 +88,6 @@ test_that("neural network prediction works", expect_true(!any(p2$Event)) - #Check that normalization is really deactivated if setting says so - x <- stationBData[100:200,-1] - m <- buildEDModel(x, dataPreparationControl = list(useNormalization = F),buildModelAlgo = "NeuralNetwork",ignoreVarianceWarning = TRUE) - excludedVariable <- length(m$excludedVariables) - newDataReal <- stationBData[201:220,-1] - p <- predict.NeuralNetwork(m,newDataReal) - expect_equal(nrow(p$predictions),nrow(newDataReal)) - expect_equal(ncol(p$predictions),(ncol(stationBData)-1-excludedVariable)) - })