Description Usage Arguments Details Value References Examples
ContextualAnomalyDetector
calculates the anomaly score of a
dataset using the notion of contexts conformed by facts and provides
probabilistic abnormality scores.
1 2 3 4 5 |
data |
Numerical vector with training and test dataset. |
rest.period |
Training period after an anomaly. |
max.left.semicontexts |
Number of semicontexts that should be maintained in memory. |
max.active.neurons |
Number of neurons of the model. |
num.norm.value.bits |
Granularity of the transformation into discrete values |
base.threshold |
Threshold to be considered an anomaly. |
min.value |
Minimum expected value. |
max.value |
Maximum expected value. |
python.object |
Python object for incremental processing. |
lib |
0 to run the original python script, 1 to get the same results on all operating systems. |
data
must be a numerical vector without NA values.
threshold
must be a numeric value between 0 and 1. If the anomaly
score obtained for an observation is greater than the threshold
, the
observation will be considered abnormal. Requires hashlib (included in python installation)
and bencode-python3 (which can be installed using pip) python libraries.
List
result |
Data frame with |
python.object |
ContextualAnomalyDetector Python object used in online anomaly detection |
Smirnov, M. (2018). CAD: Contextual Anomaly Detector. https://github.com/smirmik/CAD
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## Generate data
set.seed(100)
n <- 200
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 <- ContextualAnomalyDetector(data = df$value, rest.period = 10, base.threshold = 0.9)
## Plot results
res <- cbind(df, result$result)
PlotDetections(res, title = "CAD_OSE ANOMALY DETECTOR")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.