PlotDetections function

PLOT DETECTIONS

PLOT DETECTIONS

PlotDetections shows in a graph the results obtained after the application of one of the anomaly detectors included in this package.

PlotDetections(data, print.real.anomaly = FALSE, print.time.window = FALSE, title = "", xlab = "Time", ylab = "Value", return.ggplot = FALSE)

Arguments

  • data: data.frame composed of at least one column called timestamp and another column called value. You can also include other columns such as is.anomaly, is.real.anomaly, ucl, lcl, anomaly.score. Any of these columns except is.real.anomaly that are included in the dataset will be shown in the graph automatically.
  • print.real.anomaly: If TRUE adds the real anomalies to the graph.
  • print.time.window: If TRUE shows a time band centered on the real anomaly. According to the article shown in the reference, if the detected anomaly remains within it would be considered a true positive.
  • title: Title of the graph.
  • xlab: X Axis Name.
  • ylab: Y Axis Name.
  • return.ggplot: If TRUE the function returns a ggplot object.

Returns

plotly object.

Details

data must be a data.frame. The timestamp column can be numeric, of type POSIXlt, or a character type date convertible to POSIXlt. The value column must be numeric. is.anomaly, is.real.anomaly, ucl, lcl, anomaly.score are some of the variables returned by the algorithms included in this package and must be numeric or boolean in the case of columns is.anomaly, is.real.anomaly .

Examples

## Generate data set.seed(100) n <- 180 x <- sample(1:100, n, replace = TRUE) x[70:90] <- sample(110:115, 21, replace = TRUE) x[25] <- 200 x[150] <- 170 df <- data.frame(timestamp = 1:n, value = x) ## Calculate anomalies result <- CpSdEwma( data = df$value, n.train = 5, threshold = 0.01, l = 3 ) res <- cbind(df, result) ## Plot results PlotDetections(res, title = "KNN-CAD ANOMALY DETECTOR")

References

A. Lavin and S. Ahmad, “Evaluating Real-time Anomaly Detection Algorithms – the Numenta Anomaly Benchmark,” in 14th International Conference on Machine Learning and Applications (IEEE ICMLA’15), 2015.

  • Maintainer: Alaiñe Iturria
  • License: AGPL (>= 3)
  • Last published: 2019-09-06