Skip to main content

Python Library for Continual Lifelong Anomaly Detection

Project description

pyCLAD - Python Continual Lifelong Anomaly Detection

What is pyCLAD?

pyCLAD is a unified framework for continual anomaly detection. Its main goal is to foster successful scientific development in continual anomaly detection by providing robust implementations of strategies, models, scenarios, and metrics, complemented with code examples and user documentation. pyCLAD also facilitates the design and implementation of experimental pipelines, providing a streamlined, unified, and fully reproducible execution workflow. pyCLAD is built following a component-oriented design approach. As a result, it provides an extensible approach, where users are not required to reimplement foundational aspects of the code, and can just focus on extending specific classes.

How to use pyCLAD?

Installation

pyCLAD is provided as a Pyton package available in pypi. Therefore, you can install it as a package using tools such as pip and conda, for example:

pip install pyclad.

Moreover, the source code is available in the GitHub repository.

Optional dependencies

Depending on the anomaly detection models you want to use, you may need to install additional packages, such as tensorflow and pytorch. We do not include them in default installation to avoid putting heavy dependencies for the core installation. pyCLAD supports the use of any model from pyOD library, some of which may require installation of additional packages ( see pyOD docs.

Getting started

There are a few valuable resources supporting getting started with pyCLAD:

pyCLAD is built upon a few core concepts:

  • Scenario: a continual scenario defines the data stream so that it reflects different real-life conditions and what are the challenges faced by continual strategy.
  • Strategy: a strategy is a way to manage model updates. Continual strategy is responsible for how, when, and with which data models should be updated. Its aim is to introduce knowledge retention while keeping the ability to adapt.
  • Model: a model is a machine learning model used for anomaly detection. Models are often leveraged by continual strategies that add additional layer of managing model's updates.
  • Dataset: a dataset is a collection of data used for training and evaluation of the model.
  • Metrics: a metric is a way to evaluate the performance of the model.
  • Callbacks: a callback is a function that is called at specific points during the scenario. Callbacks are useful for monitoring the process, calculating metrics, and more.

Quick example

# Prepare random data for 3 concepts
concept1_train = Concept("concept1", data=np.random.rand(100, 10))
concept1_test = Concept("concept1", data=np.random.rand(100, 10), labels=np.random.randint(0, 2, 100))

concept2_train = Concept("concept2", data=np.random.rand(100, 10))
concept2_test = Concept("concept2", data=np.random.rand(100, 10), labels=np.random.randint(0, 2, 100))

concept3_train = Concept("concept3", data=np.random.rand(100, 10))
concept3_test = Concept("concept3", data=np.random.rand(100, 10), labels=np.random.randint(0, 2, 100))

# Build a dataset based on the previously created concepts
dataset = ConceptsDataset(
    name="GeneratedDataset",
    train_concepts=[concept1_train, concept2_train, concept3_train],
    test_concepts=[concept1_test, concept2_test, concept3_test],
)
# Define model, strategy, and callbacks
model = OneClassSVMAdapter()
strategy = CumulativeStrategy(model)
callbacks = [
    ConceptMetricCallback(
        base_metric=RocAuc(),
        metrics=[ContinualAverage(), BackwardTransfer(), ForwardTransfer()],
    ),
    TimeEvaluationCallback(),
]

# Execute the concept agnostic scenario
scenario = ConceptAgnosticScenario(dataset=dataset, strategy=strategy, callbacks=callbacks)
scenario.run()

# Save the results
output_writer = JsonOutputWriter(pathlib.Path("output.json"))
output_writer.write([model, dataset, strategy, *callbacks])

See more examples here

Citing pyCLAD

A paper describing pyCLAD is currently under review in SoftwareX journal. Feel free to use pyCLAD in your research, but please come back before your final submission to check if we already have a DOI for pyCLAD. Thank you!

How to contribute?

We welcome all contributions! If you want to contribute to pyCLAD, please follow the guidelines in the CONTRIBUTING.md file.

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

pyclad-0.1.0.tar.gz (183.8 kB view details)

Uploaded Source

Built Distribution

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

pyclad-0.1.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file pyclad-0.1.0.tar.gz.

File metadata

  • Download URL: pyclad-0.1.0.tar.gz
  • Upload date:
  • Size: 183.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for pyclad-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a4b9bcbc1b8d4ba115afaf0571c180c39ed2ed81b5bc1ebf6185a6a5e5b210d8
MD5 7b72a305c1a77850723f7a68f8e37da6
BLAKE2b-256 61f267d231690fad53d10362b28f2bc75ad4e74638430cb2766721187f9de365

See more details on using hashes here.

File details

Details for the file pyclad-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyclad-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for pyclad-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ecd242a5ca1b783eb91754e95c819634f38022ba92b9b730eaf3ad9676e9f409
MD5 29b2f64f8bb15e34cc2f1e2e47316785
BLAKE2b-256 bcb1a5408bfdd830beb76995ca96231a131aed7d133f527c9553ee55b1ee2830

See more details on using hashes here.

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