library(daltoolbox)
# Load an example anomaly dataset
data(examples_anomalies)
# Use the simple time series
dataset <- examples_anomalies$simple
head(dataset)
# Set up an ARIMA-based anomaly detector
model <- hanr_arima()
# Fit the detector
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Inspect detected events
print(detection[(detection$event),])
# Evaluate detections (soft evaluation)
evaluation <- evaluate(har_eval_soft(), detection$event, dataset$event)
print(evaluation$confMatrix)
# Plot the results
grf <- har_plot(model, dataset$serie, detection, dataset$event)
plot(grf)
Run the code above in your browser using DataLab