Convert an input of numeric data, typically a time series, into a score for anomaly detection. The data is first extended to improve the detection latency, followed by saliency map creation. The score is calculated using the sliding window average for each point in the saliency map.
Examples
tmp <- ts(rnorm(12*6,10,2), start=c(2009, 1), end=c(2014, 12), frequency=12)
anomaly_score(tmp, score_window = 25)
#> [1] 0.00000000 0.24272361 0.61073318 0.73418467 0.22755205 0.12139816
#> [7] 0.40476906 0.94009294 0.86562782 0.88056877 0.17290492 0.77448471
#> [13] 1.58034279 0.60920964 0.69237006 0.42053444 0.90379333 0.76281786
#> [19] 0.29958940 0.02337693 0.03193347 0.76537492 0.37071920 0.16445299
#> [25] 1.11449406 0.67657116 0.05438507 0.41490312 0.59366241 0.78204959
#> [31] 0.07960499 0.58519480 0.24879971 0.58570684 0.41326659 0.47852760
#> [37] 0.77944939 0.60549577 0.30267694 0.80931049 0.47744562 0.20387621
#> [43] 0.85849129 0.35800744 0.43299328 2.36788997 0.18353346 0.51356026
#> [49] 0.85130877 1.07104016 0.58225643 0.67263829 0.51877913 0.38509695
#> [55] 0.36310797 0.20756375 1.90543410 2.24857159 0.30184607 0.36776813
#> [61] 0.01506087 0.03185105 0.54585032 0.77898214 0.64068120 0.11190574
#> [67] 0.21556033 0.46531841 0.28448468 0.78307139 0.44902743 0.49008111