Skip to contents

Anomaly detection using daltoolbox regression The regression model adjusts to the time series. Observations distant from the model are labeled as anomalies. A set of preconfigured regression methods are described in https://cefet-rj-dal.github.io/daltoolbox/. They include: ts_elm, ts_conv1d, ts_lstm, ts_mlp, ts_rf, ts_svm

Usage

hanr_ml(model, sw_size = 15)

Arguments

model

DALToolbox regression model

sw_size

sliding window size

Value

hanr_ml object

Examples

library(daltoolbox)

#loading the example database
data(examples_anomalies)

#Using simple example
dataset <- examples_anomalies$simple
head(dataset)
#>       serie event
#> 1 1.0000000 FALSE
#> 2 0.9689124 FALSE
#> 3 0.8775826 FALSE
#> 4 0.7316889 FALSE
#> 5 0.5403023 FALSE
#> 6 0.3153224 FALSE

# setting up time series regression model
model <- hanr_ml(ts_elm(ts_norm_gminmax(), input_size=4, nhid=3, actfun="purelin"))

# fitting the model
model <- fit(model, dataset$serie)

detection <- detect(model, dataset$serie)

# filtering detected events
print(detection[(detection$event),])
#>       idx event    type
#> NA     NA    NA    <NA>
#> NA.1   NA    NA    <NA>
#> NA.2   NA    NA    <NA>
#> NA.3   NA    NA    <NA>
#> NA.4   NA    NA    <NA>
#> NA.5   NA    NA    <NA>
#> NA.6   NA    NA    <NA>
#> NA.7   NA    NA    <NA>
#> NA.8   NA    NA    <NA>
#> NA.9   NA    NA    <NA>
#> NA.10  NA    NA    <NA>
#> NA.11  NA    NA    <NA>
#> NA.12  NA    NA    <NA>
#> NA.13  NA    NA    <NA>
#> 50     50  TRUE anomaly