# 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](https://github.com/lifelonglab/pyCLAD).
#### 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](https://pyod.readthedocs.io/en/latest/).
### Getting started
There are a few valuable resources supporting getting started with pyCLAD:
- [Getting started guide](https://pyclad.readthedocs.io/en/latest/getting_started/)
- [Documentation](https://pyclad.readthedocs.io/en/latest/)
- [Examples available in github repository](https://github.com/lifelonglab/pyCLAD/tree/main/examples)
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
```python
# 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](https://github.com/lifelonglab/pyCLAD/tree/main/examples)**
## 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](https://github.com/lifelonglab/pyCLAD/tree/main/CONTRIBUTING.md) file.
Raw data
{
"_id": null,
"home_page": null,
"name": "pyclad",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Kamil Faber <kfaber@agh.edu.pl>, Roberto Corizzo <rcorizzo@american.edu>",
"keywords": "anomaly detection, continual anomaly detection, continual learning, lifelong learning",
"author": null,
"author_email": "Kamil Faber <kfaber@agh.edu.pl>, Roberto Corizzo <rcorizzo@american.edu>",
"download_url": "https://files.pythonhosted.org/packages/5c/38/072b45c87175018713ceb6437e8e646e6147b5affb4d7e42bb55498c868c/pyclad-0.2.0.tar.gz",
"platform": null,
"description": "# pyCLAD - Python Continual Lifelong Anomaly Detection\n\n## What is pyCLAD?\n\n**pyCLAD is a unified framework for continual anomaly detection.**\nIts main goal is to foster successful scientific development in continual anomaly detection by\nproviding robust implementations of strategies, models, scenarios, and metrics, complemented with code examples and user\ndocumentation.\npyCLAD also facilitates the design and implementation of experimental pipelines, providing a streamlined, unified, and\nfully reproducible execution workflow.\npyCLAD is built following a component-oriented design approach. As a result, it provides an extensible approach, where\nusers are not required to reimplement foundational aspects of the code, and can just focus on extending specific\nclasses.\n\n## How to use pyCLAD?\n\n### Installation\n\npyCLAD is provided as a Pyton package available in `pypi`. Therefore, you can install it as a package using tools such\nas pip and conda, for example:\n\n`pip install pyclad`.\n\nMoreover, the source code is available in [the GitHub repository](https://github.com/lifelonglab/pyCLAD).\n\n#### Optional dependencies\n\nDepending on the anomaly detection models you want to use, you may need to install additional packages,\nsuch as `tensorflow` and `pytorch`.\nWe do not include them in default installation to avoid putting heavy dependencies for the core installation.\npyCLAD supports the use of any model from pyOD library, some of which may require installation of additional packages (\nsee [pyOD docs](https://pyod.readthedocs.io/en/latest/).\n\n### Getting started\n\nThere are a few valuable resources supporting getting started with pyCLAD:\n\n- [Getting started guide](https://pyclad.readthedocs.io/en/latest/getting_started/)\n- [Documentation](https://pyclad.readthedocs.io/en/latest/)\n- [Examples available in github repository](https://github.com/lifelonglab/pyCLAD/tree/main/examples)\n\npyCLAD is built upon a few core concepts:\n\n- **Scenario**: a continual scenario defines the data stream so that it reflects different real-life conditions and what\n are\n the challenges faced by continual strategy.\n- **Strategy**: a strategy is a way to manage model updates. Continual strategy is responsible for how, when, and with\n which\n data models should be updated. Its aim is to introduce knowledge retention while keeping the ability to adapt.\n- **Model**: a model is a machine learning model used for anomaly detection. Models are often leveraged by continual\n strategies that add additional layer of managing model's updates.\n- **Dataset**: a dataset is a collection of data used for training and evaluation of the model.\n- **Metrics**: a metric is a way to evaluate the performance of the model.\n- **Callbacks**: a callback is a function that is called at specific points during the scenario. Callbacks are\n useful for monitoring the process, calculating metrics, and more.\n\n### Quick example\n\n```python\n# Prepare random data for 3 concepts\nconcept1_train = Concept(\"concept1\", data=np.random.rand(100, 10))\nconcept1_test = Concept(\"concept1\", data=np.random.rand(100, 10), labels=np.random.randint(0, 2, 100))\n\nconcept2_train = Concept(\"concept2\", data=np.random.rand(100, 10))\nconcept2_test = Concept(\"concept2\", data=np.random.rand(100, 10), labels=np.random.randint(0, 2, 100))\n\nconcept3_train = Concept(\"concept3\", data=np.random.rand(100, 10))\nconcept3_test = Concept(\"concept3\", data=np.random.rand(100, 10), labels=np.random.randint(0, 2, 100))\n\n# Build a dataset based on the previously created concepts\ndataset = ConceptsDataset(\n name=\"GeneratedDataset\",\n train_concepts=[concept1_train, concept2_train, concept3_train],\n test_concepts=[concept1_test, concept2_test, concept3_test],\n)\n# Define model, strategy, and callbacks\nmodel = OneClassSVMAdapter()\nstrategy = CumulativeStrategy(model)\ncallbacks = [\n ConceptMetricCallback(\n base_metric=RocAuc(),\n metrics=[ContinualAverage(), BackwardTransfer(), ForwardTransfer()],\n ),\n TimeEvaluationCallback(),\n]\n\n# Execute the concept agnostic scenario\nscenario = ConceptAgnosticScenario(dataset=dataset, strategy=strategy, callbacks=callbacks)\nscenario.run()\n\n# Save the results\noutput_writer = JsonOutputWriter(pathlib.Path(\"output.json\"))\noutput_writer.write([model, dataset, strategy, *callbacks])\n```\n\n**[See more examples here](https://github.com/lifelonglab/pyCLAD/tree/main/examples)**\n\n## Citing pyCLAD\n\nA paper describing pyCLAD is currently under review in SoftwareX journal. Feel free to use pyCLAD in your research, but\nplease come back before your final submission to check if we already have a DOI for pyCLAD. Thank you!\n\n## How to contribute?\n\nWe welcome all contributions! If you want to contribute to pyCLAD, please follow the guidelines in\nthe [CONTRIBUTING.md](https://github.com/lifelonglab/pyCLAD/tree/main/CONTRIBUTING.md) file.",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Python Library for Continual Lifelong Anomaly Detection",
"version": "0.2.0",
"project_urls": null,
"split_keywords": [
"anomaly detection",
" continual anomaly detection",
" continual learning",
" lifelong learning"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ef92dbd855fcff9be0016f748b2c2cdf790869d97525e2993cc25601f0c99982",
"md5": "315194169d88d9ff4979ff69047f7ef8",
"sha256": "0277ba177deb185ed6fd0e29994b8ccbdefbb19403bc38c1d3098efe942c7b0f"
},
"downloads": -1,
"filename": "pyclad-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "315194169d88d9ff4979ff69047f7ef8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 23719,
"upload_time": "2024-10-27T12:16:17",
"upload_time_iso_8601": "2024-10-27T12:16:17.364042Z",
"url": "https://files.pythonhosted.org/packages/ef/92/dbd855fcff9be0016f748b2c2cdf790869d97525e2993cc25601f0c99982/pyclad-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5c38072b45c87175018713ceb6437e8e646e6147b5affb4d7e42bb55498c868c",
"md5": "6ff4de9f768fff05532f61cd733ba898",
"sha256": "d5753978c7f5942ab334a2dcb636924923f640a42e89cb139f581eeef3e076f4"
},
"downloads": -1,
"filename": "pyclad-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "6ff4de9f768fff05532f61cd733ba898",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 48948906,
"upload_time": "2024-10-27T12:16:13",
"upload_time_iso_8601": "2024-10-27T12:16:13.482766Z",
"url": "https://files.pythonhosted.org/packages/5c/38/072b45c87175018713ceb6437e8e646e6147b5affb4d7e42bb55498c868c/pyclad-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-27 12:16:13",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pyclad"
}