Skip to contents

Multivariate anomaly detector using PCA doi:10.1016/0098-3004(93)90090-R

Usage

hmu_pca()

Value

hmu_pca object

Examples

library(daltoolbox)

#loading the example database
data(examples_harbinger)

#Using the time series 9
dataset <- examples_harbinger$multidimensional
head(dataset)
#>        serie           x event
#> 1 -0.6264538  0.40940184 FALSE
#> 2 -0.8356286  1.58658843 FALSE
#> 3  1.5952808 -0.33090780 FALSE
#> 4  0.3295078 -2.28523554 FALSE
#> 5 -0.8204684  2.49766159 FALSE
#> 6  0.5757814 -0.01339952 FALSE

# establishing hmu_pca method
model <- hmu_pca()

# fitting the model using the two columns of the dataset
model <- fit(model, dataset[,1:2])

# making detections
detection <- detect(model, dataset[,1:2])

# filtering detected events
print(detection[(detection$event),])
#>     idx event    type
#> 3     3  TRUE anomaly
#> 5     5  TRUE anomaly
#> 10   10  TRUE anomaly
#> 17   17  TRUE anomaly
#> 25   25  TRUE anomaly
#> 32   32  TRUE anomaly
#> 53   53  TRUE anomaly
#> 70   70  TRUE anomaly
#> 77   77  TRUE anomaly
#> 80   80  TRUE anomaly
#> 83   83  TRUE anomaly
#> 94   94  TRUE anomaly
#> 101 101  TRUE anomaly
#> 120 120  TRUE anomaly
#> 122 122  TRUE anomaly
#> 126 126  TRUE anomaly
#> 134 134  TRUE anomaly
#> 142 142  TRUE anomaly
#> 153 153  TRUE anomaly
#> 156 156  TRUE anomaly
#> 171 171  TRUE anomaly
#> 181 181  TRUE anomaly
#> 190 190  TRUE anomaly
#> 200 200  TRUE anomaly

# evaluating the detections
evaluation <- evaluate(model, detection$event, dataset$event)
print(evaluation$confMatrix)
#>           event      
#> detection TRUE  FALSE
#> TRUE      0     24   
#> FALSE     1     175