| Title: | A Unified Time Series Event Detection Framework |
| Version: | 1.2.747 |
| Description: | By analyzing time series, it is possible to observe significant changes in the behavior of observations that frequently characterize events. Events present themselves as anomalies, change points, or motifs. In the literature, there are several methods for detecting events. However, searching for a suitable time series method is a complex task, especially considering that the nature of events is often unknown. This work presents Harbinger, a framework for integrating and analyzing event detection methods. Harbinger contains several state-of-the-art methods described in Salles et al. (2020) <doi:10.5753/sbbd.2020.13626>. |
| License: | MIT + file LICENSE |
| URL: | https://cefet-rj-dal.github.io/harbinger/, https://github.com/cefet-rj-dal/harbinger |
| BugReports: | https://github.com/cefet-rj-dal/harbinger/issues |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.1.0) |
| RoxygenNote: | 7.3.3 |
| Imports: | tspredit, changepoint, daltoolbox, forecast, ggplot2, hht, RcppHungarian, dplyr, dtwclust, rugarch, stats, stringr, strucchange, tsmp, wavelets, zoo |
| NeedsCompilation: | no |
| Packaged: | 2025-10-27 13:25:10 UTC; eduar |
| Author: | Eduardo Ogasawara |
| Maintainer: | Eduardo Ogasawara <eogasawara@ieee.org> |
| Repository: | CRAN |
| Date/Publication: | 2025-10-27 13:50:02 UTC |
Detect events in time series
Description
Generic S3 generic for event detection using a fitted Harbinger model. Concrete methods are implemented by each detector class.
Usage
detect(obj, ...)
Arguments
obj |
A |
... |
Additional arguments passed to methods. |
Value
A data frame with columns: idx (index), event (logical), and
type (character: "anomaly", "changepoint", or ""). Some detectors may
also attach attributes (e.g., threshold) or columns (e.g., seq, seqlen).
Examples
# See detector-specific examples in the package site for usage patterns
# and plotting helpers.
Time series for anomaly detection
Description
A list of time series designed for anomaly detection tasks.
simple: simple synthetic series with isolated anomalies.
contextual: contextual anomalies relative to local behavior.
trend: synthetic series with trend and anomalies.
multiple: multiple anomalies.
sequence: repeated anomalous sequences.
tt: train-test split synthetic series.
tt_warped: warped train-test synthetic series.
#'
Usage
data(examples_anomalies)
Format
A list of time series for anomaly detection.
Source
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
data(examples_anomalies)
# Select a simple anomaly series
serie <- examples_anomalies$simple
head(serie)
Time series for change point detection
Description
A list of time series for change point experiments.
simple: simple synthetic series with one change point.
sinusoidal: sinusoidal pattern with a regime change.
incremental: gradual change in mean/variance.
abrupt: abrupt level shift.
volatility: variance change.
#'
Usage
data(examples_changepoints)
Format
A list of time series for change point detection.
Source
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
data(examples_changepoints)
# Select a simple change point series
serie <- examples_changepoints$simple
head(serie)
Time series for event detection
Description
A list of time series for demonstrating event detection tasks.
nonstationarity: synthetic nonstationary time series.
global_temperature_yearly: yearly global temperature.
global_temperature_monthly: monthly global temperature.
multidimensional: multivariate series with a change point.
seattle_week: Seattle weekly temperature in 2019.
seattle_daily: Seattle daily temperature in 2019.
#'
Usage
data(examples_harbinger)
Format
A list of time series.
Source
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
data(examples_harbinger)
# Inspect a series (Seattle daily temperatures)
serie <- examples_harbinger$seattle_daily
head(serie)
Time series for motif/discord discovery
Description
A list of time series for motif (repeated patterns) and discord (rare patterns) discovery.
simple: simple synthetic series with motifs.
mitdb100: sample from MIT-BIH arrhythmia database (record 100).
mitdb102: sample from MIT-BIH arrhythmia database (record 102).
#'
Usage
data(examples_motifs)
Format
A list of time series for motif discovery.
Source
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
data(examples_motifs)
# Select a simple motif series
serie <- examples_motifs$simple
head(serie)
Anomaly detector using autoencoders
Description
Trains an encoder-decoder (autoencoder) to reconstruct sliding windows of the series; large reconstruction errors indicate anomalies.
Usage
han_autoencoder(input_size, encode_size, encoderclass = autoenc_base_ed, ...)
Arguments
input_size |
Integer. Input (and output) window size for the autoencoder. |
encode_size |
Integer. Size of the encoded (bottleneck) representation. |
encoderclass |
DALToolbox encoder-decoder constructor to instantiate. |
... |
Additional arguments forwarded to |
Value
han_autoencoder object
References
Sakurada M, Yairi T (2014). Anomaly Detection Using Autoencoders with Nonlinear Dimensionality Reduction. MLSDA 2014.
Examples
library(daltoolbox)
library(tspredit)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure an autoencoder-based anomaly detector
model <- han_autoencoder(input_size = 5, encode_size = 3)
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Inspect detected anomalies
print(detection[detection$event, ])
Anomaly detector based on ML classification
Description
Supervised anomaly detection using a DALToolbox classifier trained with labeled events. Predictions above a probability threshold are flagged.
A set of preconfigured classification methods are listed at
https://cefet-rj-dal.github.io/daltoolbox/ (e.g., cla_majority,
cla_dtree, cla_knn, cla_mlp, cla_nb, cla_rf, cla_svm).
Usage
hanc_ml(model, threshold = 0.5)
Arguments
model |
A DALToolbox classification model. |
threshold |
Numeric. Probability threshold for positive class. |
Value
hanc_ml object.
References
Bishop CM (2006). Pattern Recognition and Machine Learning. Springer.
Hyndman RJ, Athanasopoulos G (2021). Forecasting: Principles and Practice. OTexts.
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
library(daltoolbox)
# Load labeled anomaly dataset
data(examples_anomalies)
# Use train-test example
dataset <- examples_anomalies$tt
dataset$event <- factor(dataset$event, labels=c("FALSE", "TRUE"))
slevels <- levels(dataset$event)
# Split into training and test
train <- dataset[1:80,]
test <- dataset[-(1:80),]
# Normalize features
norm <- minmax()
norm <- fit(norm, train)
train_n <- daltoolbox::transform(norm, train)
# Configure a decision tree classifier
model <- hanc_ml(cla_dtree("event", slevels))
# Fit the classifier
model <- fit(model, train_n)
# Evaluate detections on the test set
test_n <- daltoolbox::transform(norm, test)
detection <- detect(model, test_n)
print(detection[(detection$event),])
Anomaly detector using DTW
Description
Anomaly detection using DTW The DTW is applied to the time series. When seq equals one, observations distant from the closest centroids are labeled as anomalies. When seq is grater than one, sequences distant from the closest centroids are labeled as discords. It wraps the tsclust presented in the dtwclust library.
Usage
hanct_dtw(seq = 1, centers = NA)
Arguments
seq |
sequence size |
centers |
number of centroids |
Value
hanct_dtw object
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure DTW-based detector
model <- hanct_dtw()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected events
print(detection[(detection$event),])
Anomaly detector using kmeans
Description
Anomaly detection using kmeans The kmeans is applied to the time series. When seq equals one, observations distant from the closest centroids are labeled as anomalies. When seq is grater than one, sequences distant from the closest centroids are labeled as discords. It wraps the kmeans presented in the stats library.
Usage
hanct_kmeans(seq = 1, centers = NA)
Arguments
seq |
sequence size |
centers |
number of centroids |
Value
hanct_kmeans object
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure k-means detector
model <- hanct_kmeans()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected events
print(detection[(detection$event),])
Anomaly detector using ARIMA
Description
Fits an ARIMA model to the series and flags observations with large
model residuals as anomalies. Wraps ARIMA from the forecast package.
Usage
hanr_arima()
Details
The detector estimates ARIMA(p,d,q) and computes standardized residuals.
Residual magnitudes are summarized via a distance function and thresholded
with outlier heuristics from harutils().
Value
hanr_arima object.
References
Box GEP, Jenkins GM, Reinsel GC, Ljung GM (2015). Time Series Analysis: Forecasting and Control. Wiley.
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure ARIMA anomaly detector
model <- hanr_arima()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected anomalies
print(detection[(detection$event),])
Anomaly detector using EMD
Description
Empirical Mode Decomposition (CEEMD) to extract intrinsic mode functions and
flag anomalies from high-frequency components. Wraps hht::CEEMD.
Usage
hanr_emd(noise = 0.1, trials = 5)
Arguments
noise |
Numeric. Noise amplitude for CEEMD. |
trials |
Integer. Number of CEEMD trials. |
Value
hanr_emd object
References
Huang NE, et al. (1998). The empirical mode decomposition and the Hilbert spectrum for nonlinear and non-stationary time series analysis. Proc. Royal Society A.
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure EMD-based anomaly detector
model <- hanr_emd()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected anomalies
print(detection[(detection$event),])
Anomaly detector using FBIAD
Description
Anomaly detector using FBIAD
Usage
hanr_fbiad(sw_size = 30)
Arguments
sw_size |
Window size for FBIAD |
Value
hanr_fbiad object Forward and Backward Inertial Anomaly Detector (FBIAD) detects anomalies in time series. Anomalies are observations that differ from both forward and backward time series inertia doi:10.1109/IJCNN55064.2022.9892088.
References
Lima, J., Salles, R., Porto, F., Coutinho, R., Alpis, P., Escobar, L., Pacitti, E., Ogasawara, E. Forward and Backward Inertial Anomaly Detector: A Novel Time Series Event Detection Method. Proceedings of the International Joint Conference on Neural Networks, 2022. doi:10.1109/IJCNN55064.2022.9892088
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure FBIAD detector
model <- hanr_fbiad()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected anomalies
print(detection[(detection$event),])
Anomaly detector using FFT
Description
High-pass filtering via FFT to isolate high-frequency components; anomalies are flagged where the filtered magnitude departs strongly from baseline.
Usage
hanr_fft()
Details
The spectrum is computed by FFT, a cutoff is selected from the power spectrum,
low frequencies are nulled, and the inverse FFT reconstructs a high-pass
signal. Magnitudes are summarized and thresholded using harutils().
Value
hanr_fft object
References
Sobrinho, E. P., Souza, J., Lima, J., Giusti, L., Bezerra, E., Coutinho, R., Baroni, L., Pacitti, E., Porto, F., Belloze, K., Ogasawara, E. Fine-Tuning Detection Criteria for Enhancing Anomaly Detection in Time Series. In: Simpósio Brasileiro de Banco de Dados (SBBD). SBC, 29 Sep. 2025. doi:10.5753/sbbd.2025.247063
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure FFT-based anomaly detector
model <- hanr_fft()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected anomalies
print(detection[(detection$event),])
Anomaly Detector using FFT with AMOC Cutoff
Description
This function implements an anomaly detection method that uses the Fast Fourier daltoolbox::transform (FFT)
combined with an automatic frequency cutoff strategy based on the AMOC (At Most One Change)
algorithm. The model analyzes the power spectrum of the time series and detects the optimal
cutoff frequency — the point where the frequency content significantly changes — using
a changepoint detection method from the changepoint package.
All frequencies below the cutoff are removed from the spectrum, and the inverse FFT reconstructs a filtered version of the original signal that preserves only high-frequency components. The resulting residual signal is then analyzed to identify anomalous patterns based on its distance from the expected behavior.
This function extends the HARBINGER framework and returns an object of class hanr_fft_amoc.
Usage
hanr_fft_amoc()
Value
hanr_fft_amoc object
References
Sobrinho, E. P., Souza, J., Lima, J., Giusti, L., Bezerra, E., Coutinho, R., Baroni, L., Pacitti, E., Porto, F., Belloze, K., Ogasawara, E. Fine-Tuning Detection Criteria for Enhancing Anomaly Detection in Time Series. In: Simpósio Brasileiro de Banco de Dados (SBBD). SBC, 29 Sep. 2025. doi:10.5753/sbbd.2025.247063
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure FFT+AMOC detector
model <- hanr_fft_amoc()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Inspect detected anomalies
print(detection[detection$event, ])
Anomaly Detector using FFT with AMOC and CUSUM Cutoff
Description
This function implements an anomaly detection method based on the Fast Fourier daltoolbox::transform (FFT) and a changepoint-based cutoff strategy using the AMOC (At Most One Change) algorithm applied to the cumulative sum (CUSUM) of the power spectrum.
The method first computes the FFT of the input time series and extracts the power spectrum. It then applies a CUSUM transformation to the spectral data to emphasize gradual changes or shifts in spectral energy. Using the AMOC algorithm, it detects a single changepoint in the CUSUM-transformed spectrum, which serves as a cutoff index to remove the lower-frequency components.
The remaining high-frequency components are then reconstructed into a time-domain signal via inverse FFT, effectively isolating rapid or local deviations. Anomalies are detected by evaluating the distance between this filtered signal and the original series, highlighting points that deviate significantly from the expected pattern.
This method is suitable for series where spectral shifts are subtle and a single significant change in behavior is expected.
This function extends the HARBINGER framework and returns an object of class hanr_fft_amoc_cusum.
Usage
hanr_fft_amoc_cusum()
Value
hanr_fft_amoc_cusum object
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure FFT+CUSUM+AMOC detector
model <- hanr_fft_amoc_cusum()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Inspect detected anomalies
print(detection[detection$event, ])
Anomaly Detector using FFT with Binary Segmentation Cutoff
Description
This function implements an anomaly detection method that combines the Fast Fourier daltoolbox::transform (FFT) with a spectral cutoff strategy based on the Binary Segmentation (BinSeg) algorithm for changepoint detection.
The method analyzes the power spectrum of the input time series and applies the BinSeg algorithm to identify a changepoint in the spectral density, corresponding to a shift in the frequency content. Frequencies below this changepoint are considered part of the underlying trend or noise and are removed from the signal.
The modified spectrum is then transformed back into the time domain via inverse FFT, resulting in a high-pass filtered version of the series. Anomalies are identified by measuring the distance between the original and the filtered signal, highlighting unusual deviations from the dominant signal behavior.
This function is part of the HARBINGER framework and returns an object of class hanr_fft_binseg.
Usage
hanr_fft_binseg()
Value
hanr_fft_binseg object
References
Sobrinho, E. P., Souza, J., Lima, J., Giusti, L., Bezerra, E., Coutinho, R., Baroni, L., Pacitti, E., Porto, F., Belloze, K., Ogasawara, E. Fine-Tuning Detection Criteria for Enhancing Anomaly Detection in Time Series. In: Simpósio Brasileiro de Banco de Dados (SBBD). SBC, 29 Sep. 2025. doi:10.5753/sbbd.2025.247063
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure FFT+BinSeg detector
model <- hanr_fft_binseg()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Inspect detected anomalies
print(detection[detection$event, ])
Anomaly Detector using FFT with BinSeg and CUSUM Cutoff
Description
This function implements an anomaly detection method that combines the Fast Fourier daltoolbox::transform (FFT) with a changepoint-based cutoff strategy using the Binary Segmentation (BinSeg) method applied to the cumulative sum (CUSUM) of the frequency spectrum.
The method first computes the FFT of the input time series and obtains its power spectrum. Then, it applies a CUSUM transformation to the spectral density to enhance detection of gradual transitions or accumulated changes in energy across frequencies. The Binary Segmentation method is applied to the CUSUM-transformed spectrum to identify a changepoint that defines a cutoff frequency.
Frequencies below this cutoff are removed from the spectrum, and the signal is reconstructed using the inverse FFT. This produces a filtered signal that retains only the high-frequency components, emphasizing potential anomalies.
Anomalies are then detected by measuring the deviation of the filtered signal from the original one, and applying an outlier detection mechanism based on this residual.
This function extends the HARBINGER framework and returns an object of class hanr_fft_binseg_cusum.
Usage
hanr_fft_binseg_cusum()
Value
hanr_fft_binseg_cusum object
References
Sobrinho, E. P., Souza, J., Lima, J., Giusti, L., Bezerra, E., Coutinho, R., Baroni, L., Pacitti, E., Porto, F., Belloze, K., Ogasawara, E. Fine-Tuning Detection Criteria for Enhancing Anomaly Detection in Time Series. In: Simpósio Brasileiro de Banco de Dados (SBBD). SBC, 29 Sep. 2025. doi:10.5753/sbbd.2025.247063
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
#Using simple example
dataset <- examples_anomalies$simple
head(dataset)
# setting up time series fft detector
model <- hanr_fft_binseg_cusum()
# fitting the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# filtering detected events
print(detection[(detection$event),])
Anomaly Detector using Adaptive FFT and Moving Average
Description
This function implements an anomaly detection model based on the Fast Fourier daltoolbox::transform (FFT), combined with an adaptive moving average filter. The method estimates the dominant frequency in the input time series using spectral analysis and then applies a moving average filter with a window size derived from that frequency. This highlights high-frequency deviations, which are likely to be anomalies.
The residuals (original signal minus smoothed version) are then processed to compute the distance from the expected behavior, and points significantly distant are flagged as anomalies. The detection also includes a grouping strategy to reduce false positives by selecting the most representative point in a cluster of consecutive anomalies.
This function extends the HARBINGER framework and returns an object of class hanr_fft_sma.
Usage
hanr_fft_sma()
Value
hanr_fft_sma object
References
Sobrinho, E. P., Souza, J., Lima, J., Giusti, L., Bezerra, E., Coutinho, R., Baroni, L., Pacitti, E., Porto, F., Belloze, K., Ogasawara, E. Fine-Tuning Detection Criteria for Enhancing Anomaly Detection in Time Series. In: Simpósio Brasileiro de Banco de Dados (SBBD). SBC, 29 Sep. 2025. doi:10.5753/sbbd.2025.247063
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
#Using simple example
dataset <- examples_anomalies$simple
head(dataset)
# setting up time series fft detector
model <- hanr_fft_sma()
# fitting the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# filtering detected events
print(detection[(detection$event),])
Anomaly detector using GARCH
Description
Fits a GARCH model to capture conditional heteroskedasticity and flags
observations with large standardized residuals as anomalies. Wraps rugarch.
Usage
hanr_garch()
Details
A sGARCH(1,1) with ARMA(1,1) mean is estimated. Standardized residuals are
summarized and thresholded via harutils().
Value
hanr_garch object.
References
Engle RF (1982). Autoregressive Conditional Heteroscedasticity with Estimates of the Variance of United Kingdom Inflation. Econometrica, 50(4):987–1007.
Bollerslev T (1986). Generalized Autoregressive Conditional Heteroskedasticity. Journal of Econometrics, 31(3):307–327.
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure GARCH anomaly detector
model <- hanr_garch()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected anomalies
print(detection[(detection$event),])
Anomaly detector using histograms
Description
Flags observations that fall into low-density histogram bins or outside the observed bin range.
Usage
hanr_histogram(density_threshold = 0.05)
Arguments
density_threshold |
Numeric between 0 and 1. Minimum bin density to avoid being considered an anomaly (default 0.05). |
Value
hanr_histogram object
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure histogram-based detector
model <- hanr_histogram()
# Fit the model (no-op)
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected anomalies
print(detection[(detection$event),])
Anomaly detector based on ML regression
Description
Trains a regression model to forecast the next value from a sliding window and flags large prediction errors as anomalies. Uses DALToolbox regressors.
A set of preconfigured regression methods are described at
https://cefet-rj-dal.github.io/daltoolbox/ (e.g., ts_elm, ts_conv1d,
ts_lstm, ts_mlp, ts_rf, ts_svm).
Usage
hanr_ml(model, sw_size = 15)
Arguments
model |
A DALToolbox regression model. |
sw_size |
Integer. Sliding window size. |
Value
hanr_ml object.
References
Hyndman RJ, Athanasopoulos G (2021). Forecasting: Principles and Practice. OTexts.
Goodfellow I, Bengio Y, Courville A (2016). Deep Learning. MIT Press.
Examples
library(daltoolbox)
library(tspredit)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure a time series regression model
model <- hanr_ml(tspredit::ts_elm(tspredit::ts_norm_gminmax(),
input_size=4, nhid=3, actfun="purelin"))
# Fit the model
model <- daltoolbox::fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected anomalies
print(detection[(detection$event),])
Anomaly detector using REMD
Description
Anomaly detection using REMD The EMD model adjusts to the time series. Observations distant from the model are labeled as anomalies. It wraps the EMD model presented in the forecast library.
Usage
hanr_remd(noise = 0.1, trials = 5)
Arguments
noise |
nosie |
trials |
trials |
Value
hanr_remd object
References
Souza, J., Paixão, E., Fraga, F., Baroni, L., Alves, R. F. S., Belloze, K., Dos Santos, J., Bezerra, E., Porto, F., Ogasawara, E. REMD: A Novel Hybrid Anomaly Detection Method Based on EMD and ARIMA. Proceedings of the International Joint Conference on Neural Networks, 2024. doi:10.1109/IJCNN60899.2024.10651192
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure REMD detector
model <- hanr_remd()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected anomalies
print(detection[(detection$event),])
Anomaly and change point detector using RTAD
Description
Anomaly and change point detection using RTAD The RTAD model adjusts to the time series. Observations distant from the model are labeled as anomalies. It wraps the EMD model presented in the hht library.
Usage
hanr_rtad(sw_size = 30, noise = 0.001, trials = 5, sigma = sd)
Arguments
sw_size |
sliding window size (default 30) |
noise |
noise |
trials |
trials |
sigma |
function to compute the dispersion |
Value
hanr_rtad object
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
library(daltoolbox)
library(zoo)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure RTAD detector
model <- hanr_rtad()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected events
print(detection[(detection$event),])
Anomaly detector using Wavelets
Description
Multiresolution decomposition via wavelets; anomalies are flagged where aggregated wavelet detail coefficients indicate unusual energy.
Usage
hanr_wavelet(filter = "haar")
Arguments
filter |
Character. Available wavelet filters: |
Details
The series is decomposed with MODWT and detail bands are aggregated to
compute a magnitude signal that is thresholded using harutils().
Value
hanr_wavelet object
References
Mallat S (1989). A theory for multiresolution signal decomposition: The wavelet representation. IEEE Transactions on Pattern Analysis and Machine Intelligence, 11(7):674–693.
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure wavelet-based anomaly detector
model <- hanr_wavelet()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected anomalies
print(detection[(detection$event),])
Harbinger Ensemble
Description
Majority-vote ensemble across multiple Harbinger detectors with optional temporal fuzzification to combine nearby detections.
Usage
har_ensemble(...)
Arguments
... |
One or more detector objects. |
Value
A har_ensemble object
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use a simple example
dataset <- examples_anomalies$simple
head(dataset)
# Configure an ensemble of detectors
model <- har_ensemble(hanr_arima(), hanr_arima(), hanr_arima())
# model <- har_ensemble(hanr_fbiad(), hanr_arima(), hanr_emd())
# Fit all ensemble members
model <- fit(model, dataset$serie)
# Run ensemble detection
detection <- detect(model, dataset$serie)
# Show detected events
print(detection[(detection$event),])
Evaluation of event detection
Description
Hard evaluation of event detection producing confusion matrix and common metrics (accuracy, precision, recall, F1, etc.).
Usage
har_eval()
Value
har_eval object
References
Salles, R., Lima, J., Reis, M., Coutinho, R., Pacitti, E., Masseglia, F., Akbarinia, R., Chen, C., Garibaldi, J., Porto, F., Ogasawara, E. SoftED: Metrics for soft evaluation of time series event detection. Computers and Industrial Engineering, 2024. doi:10.1016/j.cie.2024.110728
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
dataset <- examples_anomalies$simple
head(dataset)
# Configure a change-point detector (GARCH)
model <- hcp_garch()
# Fit the detector
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected events
print(detection[(detection$event),])
# Evaluate detections
evaluation <- evaluate(har_eval(), detection$event, dataset$event)
print(evaluation$confMatrix)
# Plot the results
grf <- har_plot(model, dataset$serie, detection, dataset$event)
plot(grf)
Evaluation of event detection (SoftED)
Description
Soft evaluation of event detection using SoftED doi:10.48550/arXiv.2304.00439.
Usage
har_eval_soft(sw_size = 15)
Arguments
sw_size |
Integer. Tolerance window size for soft matching. |
Value
har_eval_soft object
References
Salles, R., Lima, J., Reis, M., Coutinho, R., Pacitti, E., Masseglia, F., Akbarinia, R., Chen, C., Garibaldi, J., Porto, F., Ogasawara, E. SoftED: Metrics for soft evaluation of time series event detection. Computers and Industrial Engineering, 2024. doi:10.1016/j.cie.2024.110728
Examples
library(daltoolbox)
# Load anomaly example data
data(examples_anomalies)
# Use the simple series
dataset <- examples_anomalies$simple
head(dataset)
# Configure a change-point detector (GARCH)
model <- hcp_garch()
# Fit the detector
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected events
print(detection[(detection$event),])
# Evaluate detections (SoftED)
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)
Plot event detection on a time series
Description
Convenience plotting helper for Harbinger detections. It accepts a detector, the input series, an optional detection data.frame, and optional ground-truth events to color-code true positives (TP), false positives (FP), and false negatives (FN). It can also mark detected change points and draw reference horizontal lines.
Usage
har_plot(
obj,
serie,
detection = NULL,
event = NULL,
mark.cp = TRUE,
ylim = NULL,
idx = NULL,
pointsize = 0.5,
colors = c("green", "blue", "red", "purple"),
yline = NULL
)
Arguments
obj |
A |
serie |
Numeric vector with the time series to plot. |
detection |
Optional detection data.frame as returned by |
event |
Optional logical vector with ground-truth events (same length as |
mark.cp |
Logical; if TRUE, marks detected change points with dashed vertical lines. |
ylim |
Optional numeric vector of length 2 for y-axis limits. |
idx |
Optional x-axis labels or indices (defaults to |
pointsize |
Base point size for observations. |
colors |
Character vector of length 4 with colors for TP, FN, FP, and motif segments. |
yline |
Optional numeric vector with y values to draw dotted horizontal lines. |
Value
A ggplot object showing the time series with detected events highlighted.
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
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)
Harbinger
Description
Base class for time series event detection in the Harbinger framework.
It provides common state handling and helper methods used by anomaly,
change point, and motif detectors. Concrete detectors extend this class
and implement their own fit() and/or detect() S3 methods.
Usage
harbinger()
Details
Internally, this class stores references to the original series, indices of
non-missing observations, and helper structures to restore detection results
in the original series index space. It also exposes utility hooks for
distance computation and outlier post-processing provided by harutils().
Value
A harbinger object that can be extended by detectors.
References
Harbinger documentation: https://cefet-rj-dal.github.io/harbinger
Salles, R., Escobar, L., Baroni, L., Zorrilla, R., Ziviani, A., Kreischer, V., Delicato, F., Pires, P. F., Maia, L., Coutinho, R., Assis, L., Ogasawara, E. Harbinger: Um framework para integração e análise de métodos de detecção de eventos em séries temporais. Anais do Simpósio Brasileiro de Banco de Dados (SBBD). In: Anais do XXXV Simpósio Brasileiro de Bancos de Dados. SBC, 28 Sep. 2020. doi:10.5753/sbbd.2020.13626
Examples
# See the specific detector examples for anomalies, change points, and motifs
# at https://cefet-rj-dal.github.io/harbinger
Harbinger Utilities
Description
Utility object that groups common distance measures, threshold heuristics, and outlier grouping rules used by Harbinger detectors.
Usage
harutils()
Details
Provided helpers include:
L1 and L2 distance aggregations over vectors or rows of matrices/data frames.
Thresholding heuristics: boxplot-based (IQR), Gaussian 3-sigma, and a ratio-based rule.
Grouping strategies for contiguous outliers: keep first index or keep highest-magnitude index.
Optional fuzzification over detections to propagate influence within a tolerance window.
These utilities centralize common tasks and ensure consistent behavior across detectors.
Value
A harutils object exposing the helper functions.
References
Tukey JW (1977). Exploratory Data Analysis. Addison-Wesley. (boxplot/IQR heuristic)
Shewhart WA (1931). Economic Control of Quality of Manufactured Product. D. Van Nostrand. (three-sigma rule)
Silva, E. P., Balbi, H., Pacitti, E., Porto, F., Santos, J., Ogasawara, E. Cutoff Frequency Adjustment for FFT-Based Anomaly Detectors. In: Simpósio Brasileiro de Banco de Dados (SBBD). SBC, 14 Oct. 2024. doi:10.5753/sbbd.2024.243319
Examples
# Basic usage of utilities
utils <- harutils()
# Compute L2 distance on residuals
res <- c(0.1, -0.5, 1.2, -0.3)
d2 <- utils$har_distance_l2(res)
print(d2)
# Apply 3-sigma outlier rule and keep only first index of contiguous runs
idx <- utils$har_outliers_gaussian(d2)
flags <- utils$har_outliers_checks_firstgroup(idx, d2)
print(which(flags))
At Most One Change (AMOC)
Description
Change-point detection method focusing on identifying at most one change in
mean and/or variance. This is a wrapper around the AMOC implementation from
the changepoint package.
Usage
hcp_amoc()
Details
AMOC detects a single most significant change point under a cost function optimized for a univariate series. It is useful when at most one structural break is expected.
Value
hcp_amoc object.
References
Hinkley DV (1970). Inference about the change-point in a sequence of random variables. Biometrika, 57(1):1–17. doi:10.1093/biomet/57.1.1
Killick R, Fearnhead P, Eckley IA (2012). Optimal detection of changepoints with a linear computational cost. JASA, 107(500):1590–1598.
Examples
library(daltoolbox)
# Load change-point example data
data(examples_changepoints)
# Use a simple example
dataset <- examples_changepoints$simple
head(dataset)
# Configure the AMOC detector
model <- hcp_amoc()
# Fit the detector (no-op for AMOC)
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected change point(s)
print(detection[(detection$event),])
Binary Segmentation (BinSeg)
Description
Multi-change-point detection via Binary Segmentation on mean/variance using
the changepoint package.
Usage
hcp_binseg(Q = 2)
Arguments
Q |
Integer. Maximum number of change points to search for. |
Details
Binary Segmentation recursively partitions the series around the largest detected change until a maximum number of change points or stopping criterion is met. This is a fast heuristic widely used in practice.
Value
hcp_binseg object.
References
Vostrikova L (1981). Detecting "disorder" in multidimensional random processes. Soviet Mathematics Doklady, 24, 55–59.
Killick R, Fearnhead P, Eckley IA (2012). Optimal detection of changepoints with a linear computational cost. JASA, 107(500):1590–1598. dplyr::context
Examples
library(daltoolbox)
# Load change-point example data
data(examples_changepoints)
# Use a simple example
dataset <- examples_changepoints$simple
head(dataset)
# Configure the BinSeg detector
model <- hcp_binseg()
# Fit the detector (no-op for BinSeg)
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected change points
print(detection[(detection$event),])
Change Finder using ARIMA
Description
Change-point detection by modeling residual deviations with ARIMA and applying
a second-stage smoothing and thresholding, inspired by ChangeFinder
doi:10.1109/TKDE.2006.1599387. Wraps ARIMA from the forecast package.
Usage
hcp_cf_arima(sw_size = NULL)
Arguments
sw_size |
Integer. Sliding window size for smoothing/statistics. |
Value
hcp_cf_arima object.
References
Takeuchi J, Yamanishi K (2006). A unifying framework for detecting outliers and change points from time series. IEEE Transactions on Knowledge and Data Engineering.
Examples
library(daltoolbox)
# Load change-point example data
data(examples_changepoints)
# Use a simple example
dataset <- examples_changepoints$simple
head(dataset)
# Configure ChangeFinder-ARIMA detector
model <- hcp_cf_arima()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected change points
print(detection[(detection$event),])
Change Finder using ETS
Description
Change-point detection by modeling residual deviations with ETS and applying
a second-stage smoothing and thresholding, inspired by ChangeFinder
doi:10.1109/TKDE.2006.1599387. Wraps ETS from the forecast package.
Usage
hcp_cf_ets(sw_size = 7)
Arguments
sw_size |
Integer. Sliding window size for smoothing/statistics. |
Value
hcp_cf_ets object.
Examples
library(daltoolbox)
# Load change-point example data
data(examples_changepoints)
# Use a simple example
dataset <- examples_changepoints$simple
head(dataset)
# Configure ChangeFinder-ETS detector
model <- hcp_cf_ets()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected change points
print(detection[(detection$event),])
Change Finder using Linear Regression
Description
Change-point detection by modeling residual deviations with linear regression and applying a second-stage smoothing and thresholding, inspired by ChangeFinder doi:10.1109/TKDE.2006.1599387.
Usage
hcp_cf_lr(sw_size = 30)
Arguments
sw_size |
Integer. Sliding window size for smoothing/statistics. |
Value
hcp_cf_lr object.
Examples
library(daltoolbox)
# Load change-point example data
data(examples_changepoints)
# Use a simple example
dataset <- examples_changepoints$simple
head(dataset)
# Configure ChangeFinder-LR detector
model <- hcp_cf_lr()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected change points
print(detection[(detection$event),])
Chow Test (structural break)
Description
Change-point detection for linear models using F-based structural break tests from the strucchange package doi:10.18637/jss.v007.i02. It wraps the Fstats and breakpoints implementation available in the strucchange library.
Usage
hcp_chow()
Value
hcp_chow object
Examples
library(daltoolbox)
# Load change-point example data
data(examples_changepoints)
# Use a simple example
dataset <- examples_changepoints$simple
head(dataset)
# Configure the Chow detector
model <- hcp_chow()
# Fit the detector (no-op for Chow)
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected change points
print(detection[(detection$event),])
Change Finder using GARCH
Description
Change-point detection is related to event/trend change detection. Change Finder GARCH detects change points based on deviations relative to linear regression model doi:10.1109/TKDE.2006.1599387. It wraps the GARCH model presented in the rugarch library.
Usage
hcp_garch(sw_size = 5)
Arguments
sw_size |
Sliding window size |
Value
hcp_garch object
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
library(daltoolbox)
# Load change-point example data
data(examples_changepoints)
# Use a volatility example
dataset <- examples_changepoints$volatility
head(dataset)
# Configure ChangeFinder-GARCH detector
model <- hcp_garch()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected change points
print(detection[(detection$event),])
Generalized Fluctuation Test (GFT)
Description
Structural change detection using generalized fluctuation tests via
strucchange::breakpoints() doi:10.18637/jss.v007.i02.
Usage
hcp_gft()
Value
hcp_gft object
References
Zeileis A, Leisch F, Kleiber C, Hornik K (2002). strucchange: An R package for testing for structural change in linear regression models. Journal of Statistical Software, 7(2). doi:10.18637/jss.v007.i02
Zeileis A, Kleiber C, Krämer W, Hornik K (2003). Testing and dating of structural changes in practice. Computational Statistics & Data Analysis, 44(1):109–123.
Examples
library(daltoolbox)
# Load change-point example data
data(examples_changepoints)
# Use a simple example
dataset <- examples_changepoints$simple
head(dataset)
# Configure the GFT detector
model <- hcp_gft()
# Fit the detector (no-op for GFT)
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected change points
print(detection[(detection$event),])
Pruned Exact Linear Time (PELT)
Description
Multiple change-point detection using the PELT algorithm for mean/variance
with a linear-time cost under suitable penalty choices. This function wraps
the PELT implementation in the changepoint package.
Usage
hcp_pelt()
Details
PELT performs optimal partitioning while pruning candidate change-point locations to achieve near-linear computational cost.
Value
hcp_pelt object.
References
Killick R, Fearnhead P, Eckley IA (2012). Optimal detection of changepoints with a linear computational cost. JASA, 107(500):1590–1598.
Examples
library(daltoolbox)
# Load change-point example data
data(examples_changepoints)
# Use a simple example
dataset <- examples_changepoints$simple
head(dataset)
# Configure the PELT detector
model <- hcp_pelt()
# Fit the detector (no-op for PELT)
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected change points
print(detection[(detection$event),])
Seminal change point
Description
Change-point detection is related to event/trend change detection. Seminal change point detects change points based on deviations of linear regression models adjusted with and without a central observation in each sliding window <10.1145/312129.312190>.
Usage
hcp_scp(sw_size = 30)
Arguments
sw_size |
Sliding window size |
Value
hcp_scp object
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
library(daltoolbox)
# Load change-point example data
data(examples_changepoints)
# Use a simple example
dataset <- examples_changepoints$simple
head(dataset)
# Configure seminal change-point detector
model <- hcp_scp()
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected change points
print(detection[(detection$event),])
Discord discovery using Matrix Profile
Description
Discovers rare, dissimilar subsequences (discords) using Matrix Profile as
implemented in the tsmp package doi:10.32614/RJ-2020-021.
Usage
hdis_mp(mode = "stamp", w, qtd)
Arguments
mode |
Character. Algorithm: one of "stomp", "stamp", "simple", "mstomp", "scrimp", "valmod", "pmp". |
w |
Integer. Subsequence window size. |
qtd |
Integer. Number of discords to return (>= 3 recommended). |
Value
hdis_mp object.
References
Yeh CCM, et al. (2016). Matrix Profile I/II: All-pairs similarity joins and scalable time series motifs/discrod discovery. IEEE ICDM.
Tavenard R, et al. tsmp: The Matrix Profile in R. The R Journal (2020). doi:10.32614/RJ-2020-021
Examples
library(daltoolbox)
# Load motif/discord example data
data(examples_motifs)
# Use a simple sequence example
dataset <- examples_motifs$simple
head(dataset)
# Configure discord discovery via Matrix Profile
model <- hdis_mp("stamp", 4, 3)
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected discords
print(detection[(detection$event),])
Discord discovery using SAX
Description
Discord discovery using SAX doi:10.1007/s10618-007-0064-z
Usage
hdis_sax(a, w, qtd = 2)
Arguments
a |
alphabet size |
w |
word size |
qtd |
number of occurrences to be classified as discords |
Value
hdis_sax object
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
library(daltoolbox)
# Load motif/discord example data
data(examples_motifs)
# Use a simple sequence example
dataset <- examples_motifs$simple
head(dataset)
# Configure discord discovery via SAX
model <- hdis_sax(26, 3, 3)
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected discords
print(detection[(detection$event),])
Motif discovery using Matrix Profile
Description
Discovers repeated subsequences (motifs) using Matrix Profile methods as
implemented in the tsmp package doi:10.32614/RJ-2020-021.
Usage
hmo_mp(mode = "stamp", w, qtd)
Arguments
mode |
Character. Algorithm: one of "stomp", "stamp", "simple", "mstomp", "scrimp", "valmod", "pmp". |
w |
Integer. Subsequence window size. |
qtd |
Integer. Minimum number of occurrences to classify as a motif. |
Value
hmo_mp object.
References
Yeh CCM, et al. (2016). Matrix Profile I/II: All-pairs similarity joins and scalable time series motifs/discrod discovery. IEEE ICDM.
Tavenard R, et al. tsmp: The Matrix Profile in R. The R Journal (2020). doi:10.32614/RJ-2020-021
Examples
library(daltoolbox)
# Load motif example data
data(examples_motifs)
# Use a simple sequence example
dataset <- examples_motifs$simple
head(dataset)
# Configure motif discovery via Matrix Profile
model <- hmo_mp("stamp", 4, 3)
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected motifs
print(detection[(detection$event),])
Motif discovery using SAX
Description
Discovers repeated subsequences (motifs) using a Symbolic Aggregate approXimation (SAX) representation doi:10.1007/s10618-007-0064-z. Subsequences are discretized and grouped by symbolic words; frequently occurring words indicate motifs.
Usage
hmo_sax(a, w, qtd = 2)
Arguments
a |
Integer. Alphabet size. |
w |
Integer. Word/window size. |
qtd |
Integer. Minimum number of occurrences to classify as a motif. |
Value
hmo_sax object.
References
Lin J, Keogh E, Lonardi S, Chiu B (2007). A symbolic representation of time series, with implications for streaming algorithms. Data Mining and Knowledge Discovery 15, 107–144.
Examples
library(daltoolbox)
# Load motif example data
data(examples_motifs)
# Use a simple sequence example
dataset <- examples_motifs$simple
head(dataset)
# Configure SAX-based motif discovery
model <- hmo_sax(26, 3, 3)
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected motifs
print(detection[(detection$event),])
Motif discovery using XSAX
Description
Discovers repeated subsequences (motifs) using an extended SAX (XSAX) representation that supports a larger alphanumeric alphabet.
Usage
hmo_xsax(a, w, qtd)
Arguments
a |
Integer. Alphabet size. |
w |
Integer. Word/window size. |
qtd |
Integer. Minimum number of occurrences to be classified as motifs. |
Value
hmo_xsax object.
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
Examples
library(daltoolbox)
# Load motif example data
data(examples_motifs)
# Use a simple sequence example
dataset <- examples_motifs$simple
head(dataset)
# Configure XSAX-based motif discovery
model <- hmo_xsax(37, 3, 3)
# Fit the model
model <- fit(model, dataset$serie)
# Run detection
detection <- detect(model, dataset$serie)
# Show detected motifs
print(detection[(detection$event),])
Multivariate anomaly detector using PCA
Description
Projects multivariate observations onto principal components and flags large reconstruction errors as anomalies. Based on classical PCA.
Usage
hmu_pca()
Details
The series is standardized, PCA is computed, and data are reconstructed from principal components. The reconstruction error is summarized and thresholded.
Value
hmu_pca object.
References
Jolliffe IT (2002). Principal Component Analysis. Springer.
Examples
library(daltoolbox)
# Load multivariate example data
data(examples_harbinger)
# Use a multidimensional time series
dataset <- examples_harbinger$multidimensional
head(dataset)
# Configure PCA-based anomaly detector
model <- hmu_pca()
# Fit the model (example uses first two columns)
model <- fit(model, dataset[,1:2])
# Run detection
detection <- detect(model, dataset[,1:2])
# Show detected anomalies
print(detection[(detection$event),])
# Evaluate detections
evaluation <- evaluate(model, detection$event, dataset$event)
print(evaluation$confMatrix)
Moving average smoothing
Description
The mas() function returns a simple moving average smoother of the
provided time series.
Usage
mas(x, order)
Arguments
x |
A numeric vector or univariate time series. |
order |
Order of moving average smoother. |
Details
The moving average smoother transformation is given by
(1/k) * (
x[t] + x[t+1] + ... + x[t+k-1] )
where k=order, t assume
values in the range 1:(n-k+1), and n=length(x). See also the
ma of the forecast package.
Value
Numerical time series of length length(x)-order+1 containing
the simple moving average smoothed values.
References
R.H. Shumway and D.S. Stoffer, 2010, Time Series Analysis and Its Applications: With R Examples. 3rd ed. 2011 edition ed. New York, Springer.
Examples
# Load change-point example data
data(examples_changepoints)
# Use a simple example
dataset <- examples_changepoints$simple
head(dataset)
# Compute a 5-point moving average
ma <- mas(dataset$serie, 5)
SAX transformation
Description
Symbolic Aggregate approXimation (SAX) discretization of a numeric time series.
The series is z-normalized, quantile-binned, and mapped to an alphabet of size alpha.
Usage
trans_sax(alpha)
Arguments
alpha |
Integer. Alphabet size (2–26). |
Value
A trans_sax transformer object.
References
Lin J, Keogh E, Lonardi S, Chiu B (2007). A symbolic representation of time series, with implications for streaming algorithms. Data Mining and Knowledge Discovery 15, 107–144.
Examples
library(daltoolbox)
vector <- 1:52
model <- trans_sax(alpha = 26)
model <- fit(model, vector)
xvector <- transform(model, vector)
print(xvector)
XSAX transformation
Description
Extended SAX (XSAX) discretization using a larger alphanumeric alphabet for finer symbolic resolution.
Usage
trans_xsax(alpha)
Arguments
alpha |
Integer. Alphabet size (2–36). |
Value
A trans_xsax transformer object.
References
Ogasawara, E., Salles, R., Porto, F., Pacitti, E. Event Detection in Time Series. 1st ed. Cham: Springer Nature Switzerland, 2025. doi:10.1007/978-3-031-75941-3
See Also
trans_sax
Examples
library(daltoolbox)
vector <- 1:52
model <- trans_xsax(alpha = 36)
model <- fit(model, vector)
xvector <- transform(model, vector)
print(xvector)