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.727

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.727
File Size Uploaded Provenance Actions
pyharbinger-1.0.727.tar.gz 249.5 kB Without provenance Details for pyharbinger-1.0.727.tar.gz

Built distribution (wheel)

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

Total release size: 521.9 kB

Release files / pyharbinger-1.0.727.tar.gz

Download URL pyharbinger-1.0.727.tar.gz
Size 249.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6e4afcf654152e5e786d29d348d2daf7f0db16a94d1e72ccdeb0d38c634a379f
BLAKE2b-256 checksum
How to use checksums
fdaf4a49e928f455310bdf92f61f34c22d2b0db71573b66c3b0002807b7b5141
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.727-py3-none-any.whl

Download URL pyharbinger-1.0.727-py3-none-any.whl
Size 272.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd71cb388ca2805ebcd214e1bd0252437141679b145cc927dbea03a5dcdc7e5c
BLAKE2b-256 checksum
How to use checksums
4622bac55db5d9765b122c15d80913c107de5393760b4cc506e8dc139d4394ba
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.727

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