tsanomaly
A Python library for autonomous, explainable, real-time anomaly detection on time-series metrics.
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
Examples
- quickstart.py
- cnc_vibration.py
- streaming_alerts.py
- traffic_incident.py
- root_cause.py
- gallery.py
- adaptive_envelopes.py
Documentation
- Usage guide - data formats, batch & streaming APIs, configuration, persistence, incidents, events, feedback, evaluation utilities.
- Architecture - the full pipeline.
- Examples
How it works
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
Metadata
Release files for tsanomaly 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tsanomaly-0.4.1.tar.gz | 75.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tsanomaly-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 154.1 kB
Release files / tsanomaly-0.4.1.tar.gz
| Download URL | tsanomaly-0.4.1.tar.gz |
|---|---|
| Size | 75.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86d40982bdc6bbbd32e456ba85cdd8743fe3d23976bff174fb81c8caec411fd5
|
|
BLAKE2b-256 checksum How to use checksums |
71beab5ba2be80643bf5913cd809f91cffdf2bf90178244af5b6afa4caa04749
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency logRelease files / tsanomaly-0.4.1-py3-none-any.whl
| Download URL | tsanomaly-0.4.1-py3-none-any.whl |
|---|---|
| Size | 78.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2734f96e13a69ca24a2c72bd6a61257409605a3c9ff69f9357c475c91cf6b63b
|
|
BLAKE2b-256 checksum How to use checksums |
c6a217a5324d592e5b9647acc4e5382e3a0f02d302617d87625e459d26a02023
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency logSecurity for tsanomaly 0.4.1
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for tsanomaly-0.4.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency logA 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.