Skip to main content

pyharbinger

PyPI Python versions License: MIT

Python port of the R harbinger — a framework for time series event detection (anomalies, change points, and motifs/discords), built on the DAL Toolbox Experiment Line.

pyharbinger unifies many detection methods under one interface (fit → detect → evaluate) and a common evaluation protocol, so different detectors can be compared fairly — reusing classic libraries (scikit-learn, numpy, pandas, scipy) through thin adapters and self-contained native implementations.

It is the capstone of the DAL Python family:

  • Builds on pydaltoolbox (foundation) and pytspredit (time series prediction) — its regressors power the forecasting-based anomaly detectors.

Installation

pip install pyharbinger

Quickstart

from pyharbinger import HanrFft, HarEval, datasets

# a labeled example series (one injected anomaly)
dataset = datasets.examples_anomalies()["simple"]
serie, event = dataset["serie"], dataset["event"]

# fit -> detect -> evaluate
model = HanrFft().fit(serie)
detection = model.detect(serie)
print(detection[detection["event"]])

metrics = model.evaluate(detection, event)
print(metrics["confMatrix"])
print("F1:", metrics["F1"])

What's included

Every detector extends Harbinger and returns a detection table with columns idx / event / type ("anomaly", "changepoint", "discord" or "").

Group Classes
Core Harbinger (base contract), deviation / filter / candidate-selection utilities
Evaluation HarEval (hard), HarEvalSoft (SoftED, soft matching via the Hungarian algorithm)
Anomaly HanrMl (forecasting residuals, wraps a pytspredit regressor), HanrArima (ARIMA residuals, reuses the DAL ARIMA), HanrFft, HanrFftAmoc, HanrFftBinseg, HanrFftAmocCusum, HanrFftBinsegCusum, HanrFftSma (adaptive FFT-selected moving average), HanrHistogram, HanrFbiad, HanrEmd, HanrRemd, HanrRtad, HanrWavelet (native MODWT, reuses pytspredit), HanrGarch
Change point HcpAmoc, HcpBinseg, HcpPelt, HcpKswin, HcpPageHinkley, HcpCfLr, HcpScp, HcpJoinpoint, HcpChow, HcpGft, HcpCfArima, HcpCfEts, HcpGarch, HcpBocpd
Clustering HanctKmeans, HanctDtw (anomalies / discords)
Classification HancMl (supervised; wraps a pydaltoolbox classifier)
Multivariate HmuPca (PCA reconstruction error)
Motifs & Discords HmoMp, HdisMp (Matrix Profile), TransSax / TransXsax (SAX / XSAX encoding), HmoSax / HmoXsax (motifs), HdisSax (discords)
Ensemble HarEnsemble (majority vote), HarEnsembleFuzzy (fuzzy consensus)
Plotting har_plot, har_ensemble_plot, har_ensemble_plot_models (matplotlib)
Online / streaming HarOnlineSession + sources (HarSourceSimulated/HarSourceDataframe/HarSourceCallback/HarSourceKafka + collector seam), memory policies, execution strategies; HarStreamEval + har_stream_experiment
Datasets datasets.examples_anomalies(), datasets.examples_changepoints(), datasets.examples_motifs(), datasets.examples_harbinger(); benchmark collection via datasets.benchmark() / datasets.loadfulldata() (Yahoo, gecco, MIT-BIH, NAB, oil_3w, UCR)

Detectors accept a univariate series or, for the multivariate ones, a DataFrame with one column per variable.

Guided Tutorial Track

If you are new to pyharbinger, start with the guided tutorials in the GitHub examples collection:

  • Tutorials — a 10-part sequential learning path covering first contact with the package, data inspection, plotting, baseline anomaly detection, model-based detection, evaluation, change points, smoothing, symbolic encodings, and motif discovery.

Thematic Example Collections

If you already know the basic fit → detect → evaluate workflow, jump directly to any thematic example collection on GitHub:

  • General examples — orientation datasets, deviation measures, filter criteria, candidate selection, and hard/soft evaluation.
  • Dataset examples — benchmark archives (Yahoo, NAB, UCR) and domain collections (MIT-BIH, Oil 3W, GECCO).
  • Transformation examples — moving-average smoothing (mas) and symbolic encodings (TransSax, TransXsax).
  • Anomaly examples — baseline, spectral, decomposition, statistical, ML regression, supervised classification, clustering, discord, ensemble, and multivariate anomaly detectors. Deep-learning detectors (HanAutoencoder) live in pydaltoolboxdp.
  • Change-point examples — single-break, multiple-break, structural-break, ChangeFinder, volatility, window, BOCPD, ensemble, and streaming drift detectors. Deep-learning HcpWaypoint lives in pydaltoolboxdp.
  • Motif examples — Matrix Profile (HmoMp, HdisMp) and symbolic (HmoSax, HmoXsax, HdisSax) motif and discord discovery.
  • Online examples — streaming sources, online sessions, memory policies, execution strategies, stream evaluation, experiment grids, and the dependency-free Kafka collector seam.
  • Custom examples — extending pyharbinger with custom transformations, anomaly/sequence/change-point/motif detectors, and custom evaluators.

Main Capabilities

  • Unified abstractions for event detectors, transformations, ensembles, evaluators, online sessions, and data sources.
  • Anomaly detection through statistical, spectral, decomposition, residual, machine-learning, supervised classification, clustering, discord, ensemble, and multivariate approaches.
  • Change-point detection through single-break, multiple-break, structural-break, probabilistic (BOCPD), volatility (GARCH), ChangeFinder, window, ensemble, and streaming/online approaches.
  • Motif and discord discovery using Matrix Profile and symbolic (SAX / XSAX) representations.
  • Time series transformations including moving-average smoothing (mas), SAX, and extended SAX (TransSax, TransXsax).
  • Evaluation and visualization with hard (HarEval) and soft (HarEvalSoft / SoftED) evaluation protocols, plotting utilities (har_plot, har_ensemble_plot), and reproducible streaming experiments (HarOnlineSession, HarStreamEval).

License

MIT

Metadata

Release files for pyharbinger 1.0.717

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyharbinger 1.0.717
File Size Uploaded Provenance Actions
pyharbinger-1.0.717.tar.gz 250.0 kB Without provenance Details for pyharbinger-1.0.717.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyharbinger 1.0.717
File Interpreter ABI Platform Actions
pyharbinger-1.0.717-py3-none-any.whl Python 3 none any Details for pyharbinger-1.0.717-py3-none-any.whl

Total release size: 522.8 kB

Release files / pyharbinger-1.0.717.tar.gz

Download URL pyharbinger-1.0.717.tar.gz
Size 250.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1bcc16044f9028ae8373e044a48828cbfa198ec486d079dc676a140f5eaee070
BLAKE2b-256 checksum
How to use checksums
7924ed6d269cf21004c4ae6fce2a4061edc66bfc347bde7fcc56cc027073cd1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / pyharbinger-1.0.717-py3-none-any.whl

Download URL pyharbinger-1.0.717-py3-none-any.whl
Size 272.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76bcf0a92da6f34a5c8c1022c85a8468b0b07356087ef4ccba526adbd45ad800
BLAKE2b-256 checksum
How to use checksums
d427443c296cba3cb347ed2ddde19db9e39bd35d3dadafb8d780fc61903e49cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Security for pyharbinger 1.0.717

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page