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 dataset.seed(100)n <-180x <- sample(1:100, n, replace =TRUE)x[70:90]<- sample(110:115,21, replace =TRUE)x[25]<-200x[150]<-170df <- data.frame(timestamp =1:n, value = x)## Calculate anomaliesresult <- CpSdEwma( data = df$value, n.train =5, threshold =0.01, l =3)res <- cbind(df, result)## Plot resultsPlotDetections(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.