GetWindowsLimits: Get windows limits

Description Usage Arguments Details Value References Examples

View source: R/GetDetectorScore_getWindowsLimits.R

Description

GetWindowsLimits Calculates the start and end positions of each window that are focused on the real anomalies. This windows can be used to know if the detected anomaly is a true positive or not.

Usage

1
GetWindowsLimits(data, windowLength = NULL)

Arguments

data

All dataset with training and test datasets and with at least timestamp, value and is.real.anomaly columns.

windowLength

Window length. See GetWindowLength.

Details

data must be a data.frame with timestamp, value, is.anomaly and is.real.anomaly columns. timestamp column can be numeric, of type POSIXct, or a character type date convertible to POSIXct. windowLength must be numeric value.

Value

Same data set with two additional columns start.limit and end.limit where for each is.real.anomaly equal to 1 is indicated the position in the data set where each window starts and ends. If two anomalies fall within the same window, the start and end positions are only indicated on the first of them.

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## 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)

# Add is.real.anomaly column
df$is.real.anomaly <- 0
df[c(25,80,150), "is.real.anomaly"] <- 1

# Get Window Limits
data <- GetWindowsLimits(df)
data[data$is.real.anomaly == 1,]

otsad documentation built on Sept. 6, 2019, 5:02 p.m.