Skip to main content

ANODI

This is the Python library ANODI for Time Series Anomaly Detection. It offers easy access to algorithms and benchmark data.

Short Description

  • the core of the ANODI library is the algorithm class (anodilib.algorithm) that wrapps an algorithm and the data that the algorithm should be fit on. It has - for example - the following attributes:
    • self.X_train_df, self.Y_train_df, self.X_test_df, self.Y_test_df: Dataframes for train and test data and labels
    • train_dls, test_dls: Dataloaders (fastAI Usage) for train and test data
    • learner: The Learner object for fastAI
    • most of the algorithms have additional attributes for window_length, stride and batch_size
  • the data and some meta arguments are set up as a DatasetSpecification in the data module and given as argument to the algorithm object.
    • If not overriden by another test-DatasetSpecification in the predict function, the given data behind des DatasetSpecification is automatically split into the Dataframes and Dataloaders from above using the parameter test_fraction
  • ANODI offers the following modules: algorithm, data, metrics, model(containing the underlying pytorch models), visualization

Example Usage

  • Example Usage of IsolationForest Algorithm on the ECG200_TRAIN Dataset:
from anodilib.algorithm.IsolationForest import IsolationForest as IF
from anodilib.data.DatasetSpecification import ECG200_TRAIN

alg = IF(dataset_specification=ECG200_TRAIN, contamination="auto", test_fraction=0.2)
alg.fit()
alg.predict()
anoms = alg.getAnomalies()

print(anoms)
  • Example Usage of ModifiedLSTM Algorithm on the ECG200_TRAIN Dataset using c_f1_score Metric:
from anodilib.algorithm.ModifiedLSTM import ModifiedLSTM
from anodilib.data.DatasetSpecification import ECG200_TRAIN
from metrics.cmetrics import c_f1_score
import numpy as np

alg = ModifiedLSTM(dataset_specification=ECG200_TRAIN, batch_size=28,window_len=4, stride=1)

alg.fit(epoch_num=50, learning_rate="lr_find",learning_rate_iteration=200)
alg.fit(epoch_num=50, learning_rate="lr_find",learning_rate_iteration=200)
alg.fit(epoch_num=50, learning_rate="lr_find",learning_rate_iteration=200)
alg.fit(epoch_num=50, learning_rate="lr_find",learning_rate_iteration=200)

alg.predict()

anoms, _ , _ = alg.getAnomalies()
print(anoms)
print(c_f1_score(anoms, np.array(alg.Y_test_df)))
  • Example on how to put your local data into a DatasetSpecification (here: WADI Dataset)
from anodilib.data.DatasetSpecification import DatasetSpecification

WADI = DatasetSpecification(
    dataset_name="WADI.A2_19_Nov_2019_WADI_attackdataLABLE.csv",
    location=None,
    delimiter=",",
    label_column=130, # column containing the label
    is_data_column=lambda c: c != 130 and c >= 3, # use data of columns
    columns=None,
    skip_header=3,
    skip_footer=3,
    label_realizations=[1, -1],
    decimal=".",
    only_first_n_entries=-1, # if -1, use all entries
    predefined_dataset=None,
)

# use for algorithms ...

Dev Installation

This package is built using poetry, run the following code to install an editable version of the package for development

pip install poetry
poetry install

Metadata

Release files for anodilib 0.1.5

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

Source distribution (sdist)

Source distribution for anodilib 0.1.5
File Size Uploaded Provenance Actions
anodilib-0.1.5.tar.gz 7.8 MB Without provenance Details for anodilib-0.1.5.tar.gz

Built distribution (wheel)

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

Total release size: 15.6 MB

Release files / anodilib-0.1.5.tar.gz

Download URL anodilib-0.1.5.tar.gz
Size 7.8 MB
Tags Source
SHA-256 checksum
How to use checksums
550e2bdc61582924012b535fea3da7c52f67740f00a41da6393fb5e3f97b4b3d
BLAKE2b-256 checksum
How to use checksums
0d7d4dd2c142d11e76721847efdef0785f0ec42e6860ce66fc1de3a12eb75557
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.9.6 Darwin/23.4.0

Release files / anodilib-0.1.5-py3-none-any.whl

Download URL anodilib-0.1.5-py3-none-any.whl
Size 7.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
b94fae0058826d8e94305e3ab11a9415d297e75b485ee441591e85daaaa132b1
BLAKE2b-256 checksum
How to use checksums
5ffd2ccef1b46b3e6302f53a28adc3f74ba85b5b9218c2109c10ae62bc8c8104
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.9.6 Darwin/23.4.0

Security for anodilib 0.1.5

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.

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files No provenance

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