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.0a1.tar.gz (180.9 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.0a1-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyclad-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 2644d085fec3a64b7bd2ca15b952b5491b90c5e9b0c880bb065b09a5bebfbf6f
MD5 d8978440cedd0265833bfdfc17515bec
BLAKE2b-256 5a39974e2a51e063b2f18ce88f29f48fd00e237729957116698a4eabfc9e0644

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyclad-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 88aa5bd10f0749642647b58b4c6e23ebea3566ae4c343eeec4d217b8fd6abfca
MD5 0909194773c56b3ba20b2910f998f770
BLAKE2b-256 a1e110539e9bab86133789635f856ca23454d97ad124b151446053a3eb3c14ea

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