Description Usage Arguments Details Value References Examples
View source: R/PlotDetections.R
PlotDetections
shows in a graph the results obtained after the application
of one of the anomaly detectors included in this package.
1 2 3 |
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. |
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 .
plotly object.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## 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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.