Skip to main content

tsanomaly

A Python library for autonomous, explainable, real-time anomaly detection on time-series metrics.

CI PyPI Python versions License

pip install tsanomaly
tsanomaly detect metrics.csv     # or straight from the terminal

Why tsanomaly

  • Nothing to configure - feed it raw metrics; the sampling interval, daily/weekly patterns, model choice, and expected range are learned per metric. No thresholds to set or maintain.
  • Few false alarms - the expected range is continuously checked against what actually happens (adaptive conformal inference), and how rare a deviation is comes from the metric's own history (extreme value theory), not a bell-curve assumption that breaks on real data.
  • One threshold works everywhere - every anomaly gets a 0-100 score from how far, how long, and how persistent. A 90 means the same rarity on any metric, so you can rank and alert across metrics with a single cutoff.
  • A level shift alerts once - when a metric permanently moves (a deploy, a config change), you get one "new normal" finding and the baseline re-anchors, not days of repeat alerts.
  • Related alerts arrive as one incident - metrics that break together are grouped into a single finding, ordered by which moved first: a starting point for root cause.
  • Built for streaming - O(1) per-sample updates, out-of-order tolerance, an opened/escalated/closed alert lifecycle with pluggable sinks, silent-metric detection, checkpoint/restore.
  • Every alert explains itself - the expected range it broke, the score breakdown, what the model learned from which data, and the value that would not have alerted.

Quickstart

import pandas as pd
import tsanomaly as tsa

# any long frame with metric / timestamp / value columns
history = pd.read_csv("payments.csv", parse_dates=["ts"])

det = tsa.Detector.auto()
det.fit(history)                      # learn normal, per metric
result = det.detect(new_data)         # scored, explained anomalies

print(result.summary())
for anomaly in result.alerts(min_score=70):
    print(anomaly.explain().to_text())

Output (NYC taxi ridership around the January 2015 blizzard):

learned seasonality: day (strength 0.67), week (strength 0.84)

`nyc.taxi.passengers` dropped to 7076 (expected 15912.1 to 27621.4)
    for 30.5 h starting 2014-11-27 05:30 UTC - score 100.   # Thanksgiving
`nyc.taxi.passengers` dropped to 4729 (expected 17111.8 to 26890.1)
    for 9.5 h starting 2015-01-26 14:30 UTC - score 100.    # blizzard arrives
`nyc.taxi.passengers` dropped to 570 (expected 7971.81 to 24646.4)
    for 16.0 h starting 2015-01-27 06:00 UTC - score 100.   # blizzard travel ban
quickstart: NYC taxi ridership with detected anomalies

Examples

CNC mill vibration with the two Bosch-labeled bad cycles surfaced

Documentation

  • Usage guide - data formats, batch & streaming APIs, configuration, persistence, incidents, events, feedback, evaluation utilities.
  • Architecture - the full pipeline.
  • Examples

How it works

the tsanomaly pipeline

For more details, refer to docs/architecture.md.

Acknowledgements

The autonomous per-metric architecture is inspired by ideas in Anodot's published patents, implemented here with different, modern mechanisms - see the acknowledgements in docs/architecture.md.

License

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tsanomaly-0.4.0.tar.gz (75.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tsanomaly-0.4.0-py3-none-any.whl (78.4 kB view details)

Uploaded Python 3

File details

Details for the file tsanomaly-0.4.0.tar.gz.

File metadata

  • Download URL: tsanomaly-0.4.0.tar.gz
  • Upload date:
  • Size: 75.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for tsanomaly-0.4.0.tar.gz
Algorithm Hash digest
SHA256 a595b2c992981fd37ed2f3ca5a9a1f71eddef0602fec5e81ca9da8bcb1ab8627
MD5 e33df21d1a7379e8734d056d6d5c9b20
BLAKE2b-256 f12f797475833c8b1f94c8979888fe3e2e26977a858e0386075159d20de7a5a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsanomaly-0.4.0.tar.gz:

Publisher: release.yml on visakhunnikrishnan/tsanomaly

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tsanomaly-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: tsanomaly-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 78.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for tsanomaly-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c034d6d2936261d07f6004d14a005da1458498e82a0a50e1f61ddbcb9f7709b
MD5 e3bba774bca55132d6575655f6929c20
BLAKE2b-256 bcd57599c3ef7e3c42581bbe967afae8e1f19639aace2c1f535b7bb46606375d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsanomaly-0.4.0-py3-none-any.whl:

Publisher: release.yml on visakhunnikrishnan/tsanomaly

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.4.1

2 files

This release

0.4.0 This release

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

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