This repository acts as a base for Datamole's time series anomaly detection assignments.
-
Poetry environment file
pyproject.toml
specifies python packages version requirements. In case you decide to use Python package listed there, the used version must conform to it. Use poetry and base your environment on the providedpyproject.toml
. There are also extra dependencies specified inpyproject.toml
(e.g. tensorflow). If you decide to use one of these dependencies, make sure that your version conforms to it. -
File
time_series_anomaly_detection/abstractions.py
contains Python module with abstract classTimeSeriesAnomalyDetector
. Your anomaly detector must implement this class. Make sure that the abstract methods are implemented according to their documentation. -
File
time_series_anomaly_detection/detector.py
contains Python module withTemplateDetector
which you can use as base for your anomaly detector. As you can see the detector takesid_columns
parameter in its constructor. Your detector should also take this parameter as it's necessary to fulfill requirements for the functionality of anomaly detector. -
File
tests/test_detector.py
contains pytest module with simple tests that your detector must pass. Make sure thatDETECTOR_CLASS
points to your detector. In case your detector contains additional required parameters (in its constructor), modify existing tests so that these parameters are filled. Adding of additional unit tests is welcome but do not change predefined unit tests except for the mentioned exceptions. -
The anomaly detector should be able to handle numerical data with missing values (nan values). In case the paper introducing the detector does not mention it and there is not a clear solution you can relax on it. For example in case the detector is working with certain window size, ignoring (window size - 1) samples after sample with a missing value is a possible solution (nan anomaly score should be returned for each ignored sample).
-
The anomaly detector must be able to handle multiple time series which are identified by the ID columns whose names are provided in the constructor argument
id_columns
. These columns should only be used to separate individual time series (not as feature columns). In case the paper introducing the detector does not mention training on multiple time series, try to come up with a reasonable solution. If there is not a clear reasonable solution you can relax on it. -
Your solution must be in your github repository. You should develop your solution in a non-master branch and the pull request to master branch should be used as a place for our review.
-
Each function and class must be documented using numpy style docstring.
-
Fork this repository. Create a new branch for the solution.
-
Install poetry and read its documentation.
-
Install poetry environment by running
poetry install
inside the project's folder. -
Rename
TemplateDetector
intime_series_anomaly_detection/detector
to the name of your anomaly detector and start implementing it (the documentation ofpredict_anomaly_scores
andfit
is inherited fromTimeSeriesAnomalyDetector
and can be found intime_series_anomaly_detection/abstractions.py
. -
Make sure that your detector passes all tests in
tests/test_detector.py
by runningpoetry run python -m pytest tests
. First make sure that in the beginning oftests/test_detector.py
constant DETECTOR_CLASS points to your anomaly detector and not toTemplateDetector
(in case you renamed it). In case your detector contains additional required parameters (in its constructor), modify tests so that these parameters are filled. -
Create pull request of the solution branch to the master branch.