EorelmAD: Ensemble based online recurrent extream learning machine...

EorelmADR Documentation

Ensemble based online recurrent extream learning machine anomaly detector (EORELM-AD)

Description

R6 class that implements our ensemble-based online recurrent extreme learning machine anomaly detector (EORELM-AD). EORELM-AD is an online univariate time series anomaly detector based on an online recurrent extreme learning machine (OR-ELM) prediction model proposed by J. M. Park and J. H. Kim (2017) <doi:10.1109/IJCNN.2017.7966094>. ORELM is an online learning algorithm that trains single-hidden layer feedforward neural networks (SLFNs), able to learn data one-by-one or chunk-by-chunk with fixed or varying data size.

Details

EORELM-AD implements several online normalization techniques needed to train ORLEM. Then, based on a window of normalized previous values it predicts the value of the current data point using an ensemble of OR-ELMs initialized with different parameters. Finally, the anomaly score and the anomaly label are computed based on past prediction errors. For this aim, several scoring methods are available.

Methods

Public methods


Method new()

Create a new EorelmAD object.

Usage
EorelmAD$new(
  n.train,
  numLags = 100,
  ncomb = 30,
  k = 6,
  numHiddenNeurons = c(20, 25, 30, 35, 40, 45, 50),
  outputWeightForgettingFactor = seq(0.9, 1, 0.01),
  inputWeightForgettingFactor = 1,
  normMethod = "DN",
  normParams = NULL,
  outlierMethod = "DS",
  outlierParams = list(),
  threshold = 0.5,
  reduceFP = FALSE
)
Arguments
n.train

Number of points of the dataset that correspond to the training set. n.train must be greater or equal to numLags + 2.

numLags

Number of past values needed to make the prediction. numLags must be lower or equal to n.train - 2.

ncomb

Number of base learners to initialize during the training stage.

k

Numer of best base learners to be used during the test stage.

numHiddenNeurons

Number or vector of possible values of hidden neurons.

outputWeightForgettingFactor

Value or vector of possible values of the output weight forgetting factor. All values must be between 0 and 1. If it is 1, it does not forget anything.

inputWeightForgettingFactor

Value or vector of possible values of the input weight forgetting factor. All values must be between 0 and 1. If it is 1, it does not forget anything.

normMethod

The normalization method to be used. Possible values are: NULL, "WN", "DN", "OAN", and "OAMN". Note that if the value of normMethod is NULL, the input data must be previously normalized or standardized.

normParams

A list with the additional parameters to configure selected normMethod; by default NULL. Please for more details see, WindowNormalizer (WN), DynamicNormalizer (DN), AdaptiveNormalizer (OAN), AdaptiveNormalizer2 (OAMN).

outlierMethod

The outlier method to be used to compute the anomaly score based on historical prediction errors. Possible values are: "AL", "DT", "SS" and "DSS".

outlierParams

A list with the additional parameters to configure selected outlierMethod; by default empty list. Please for more details see, AnomalyLikelihoodScorer(AL), DynamicThresholdScorer (DT), SigmaScorer (SS) and DynamicSigmaScorer (DSS).

threshold

Anomaly threshold. A integer value between [0,1].

reduceFP

If TRUE reduces false positives.

Returns

A new EorelmAD object.


Method predict()

It determines whether or not the current value is an anomaly and its degree of abnormality.

Usage
EorelmAD$predict(x)
Arguments
x

New data value to be evaluated.

Returns

Dataset conformed by the following columns:

predictedInput Standardized predicted value for the current input x.
normalizedInput Normalized value of the current input x.
error Prediction error.
is.anomaly 1 if the value is anomalous, 0 otherwise.
anomaly.score Probability of anomaly.

References

J. M. Park and J. H. Kim, Online recurrent extreme learning machine and its application to time-series prediction, in Proceedings of the International Joint Conference on Neural Networks, 2017, pp. 1983–1990.

Examples


## Generate data
set.seed(100)
n <- 350
x <- sample(1:100, n, replace = TRUE)
x[70:90] <- sample(110:115, 21, replace = TRUE)
x[25] <- 200
x[320] <- 170
df <- data.frame(timestamp = 1:n, value = x)


## Calculate anomalies
detector <- EorelmAD$new(
  n.train = 20,
  numLags = 10,
  numHiddenNeurons = c(20),
  normMethod = NULL,
  outlierMethod = "DSS",
  threshold = 0.5
)
result <- detector$predict(df$value)

## Plot results
res <- cbind(df, result)
PlotDetections(res, title = "EORELM-AD ANOMALY DETECTOR", return.ggplot = TRUE)


alaineiturria/otsad documentation built on Jan. 12, 2023, 12:26 p.m.