Skip to main content

PySAD is an open-source python framework for anomaly detection on streaming multivariate data.

Project description

https://github.com/selimfirat/pysad/raw/master/docs/logo.png

Python Streaming Anomaly Detection (PySAD)

PyPI GitHub release (latest by date) Documentation status Azure Pipelines Build Status Travis CI Build Status Appveyor Build status Circle CI Coverage Status PyPI - Python Version Supported Platforms License

PySAD is an open-source python framework for anomaly detection on streaming multivariate data.

Documentation

Features

Online Anomaly Detection

PySAD provides methods for online/sequential anomaly detection, i.e. anomaly detection on streaming data, where model updates itself as a new instance arrives.

Resource-Efficient

Streaming methods efficiently handle the limitied memory and processing time requirements of the data streams so that they can be used in near real-time. The methods can only store an instance or a small window of recent instances.

Complete

PySAD contains stream simulators, evaluators, preprocessors, statistic trackers, postprocessors, probability calibrators and more. In addition to streaming models, PySAD also provides integrations for batch anomaly detectors of the PyOD so that they can be used in the streaming setting.

Comprehensive

PySAD serves models that are specifically designed for both univariate and multivariate data. Furthermore, one can experiment via PySAD in supervised, semi-supervised and unsupervised setting.

User Friendly

Users with any experience level can easily use PySAD. One can easily design experiments and combine the tools in the framework. Moreover, the existing methods in PySAD are easy to extend.

Free and Open Source Software (FOSS)

PySAD is distributed under BSD License 2.0 and favors FOSS principles.

Installation

The PySAD framework can be installed via:

pip install -U pysad

Alternatively, you can install the library directly using the source code in Github repository by:

git clone https://github.com/selimfirat/pysad.git
cd pysad
pip install .

Required Dependencies:

  • Python: 3.10+

  • numpy: 2.1.3

  • scikit-learn: 1.5.2

  • scipy: 1.15.3

  • statsmodels: 0.14.4 (for pysad.models.SeasonalESD, pysad.models.SeasonalHybridESD and pysad.transform.preprocessing.ModifiedSTLResidualTransformer)

  • pyod: 3.5.2

  • combo: 0.1.3

Optional Dependencies:

  • rrcf: 0.4.4 (for pysad.models.robust_random_cut_forest.RobustRandomCutForest)

  • PyNomaly: 0.3.5 (for pysad.models.loop.StreamLocalOutlierProbability)

  • mmh3: 2.5.1 (for pysad.models.xstream.xStream)

  • pandas: 2.2.3 (for pysad.utils.pandas_streamer.PandasStreamer)

  • jax: >=0.6.1 (for pysad.models.inqmad.Inqmad; required for NumPy 2.0+ compatibility of this module)

  • jaxlib: >=0.6.1 (for pysad.models.inqmad.Inqmad; required for NumPy 2.0+ compatibility of this module)

Examples

Quick Start

Here’s a simple example showing how to use PySAD for anomaly detection on streaming data:

# Import modules.
from pysad.evaluation import AUROCMetric
from pysad.models import LODA
from pysad.utils import Data


model = LODA()  # Init model
metric = AUROCMetric()  # Init area under receiver-operating- characteristics curve metric
streaming_data = Data().get_iterator("arrhythmia.mat")  # Get data streamer.

for x, y_true in streaming_data:  # Stream data.
    anomaly_score = model.fit_score_partial(x)  # Fit the instance to model and score the instance.

    metric.update(y_true, anomaly_score)  # Update the AUROC metric.

# Output the resulting AUROCMetric.
print(f"Area under ROC metric is {metric.get()}.")

Contributors

Contributors

We thank all our contributors for their valuable input and efforts to make PySAD better!

Versioning

Semantic versioning is used for this project.

License

This project is licensed under the BSD License 2.0.

Citing PySAD

If you use PySAD for a scientific publication, please cite the following paper:

@article{pysad,
  title={PySAD: A Streaming Anomaly Detection Framework in Python},
  author={Yilmaz, Selim F and Kozat, Suleyman S},
  journal={arXiv preprint arXiv:2009.02572},
  year={2020}
}

Project details


Download files

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

Source Distribution

pysad-0.5.0.tar.gz (65.0 kB view details)

Uploaded Source

Built Distribution

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

pysad-0.5.0-py3-none-any.whl (74.2 kB view details)

Uploaded Python 3

File details

Details for the file pysad-0.5.0.tar.gz.

File metadata

  • Download URL: pysad-0.5.0.tar.gz
  • Upload date:
  • Size: 65.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pysad-0.5.0.tar.gz
Algorithm Hash digest
SHA256 7c2e166a1ff2f5e3dc8eafded53bbeac82e338394de0e1b4b629ea60e0737451
MD5 b324969bea625c3d6222b4333f5c50f5
BLAKE2b-256 3eb0e5c9fccab6325de2ec04b0887d8ac7181db15a6f8f87372c8388f3e4f81d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysad-0.5.0.tar.gz:

Publisher: publish.yml on selimfirat/pysad

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

File details

Details for the file pysad-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pysad-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 74.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pysad-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec565717e7888f9ff185d1cc923a37f77525c210b1bc3ed92d9ac5f6bddf1e98
MD5 8fc3463b62785dbbd2675b9cef726cd8
BLAKE2b-256 32ddb2dd2e291954a72cf7dcb1174f8ee9e1c3d673d931c41093381939daa085

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysad-0.5.0-py3-none-any.whl:

Publisher: publish.yml on selimfirat/pysad

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page