-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalgorithm_interface.py
More file actions
47 lines (35 loc) · 1.5 KB
/
algorithm_interface.py
File metadata and controls
47 lines (35 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""Contains the algorithm base class."""
from abc import ABC, abstractmethod
import pandas as pd
from .algorithm_config import *
from .algorithm_information import *
__all__ = ["AlgorithmInterface"]
class AlgorithmInterface(ABC):
"""The base class for all anomaly detection algorithms."""
@property
@abstractmethod
def information(self) -> AlgorithmInformation:
"""Returns an AlgorithmInformation object containing all information regarding the algorithm.
Returns:
An AlgorithmInformation object containing all information regarding the algorithm.
"""
pass
@property
@abstractmethod
def configuration(self) -> AlgorithmConfig:
"""Returns an AlgorithmConfig object containing all information regarding the config options for the algorithm.
Returns:
An AlgorithmConfig object containing all information regarding the config options.
"""
pass
@abstractmethod
def calc_anomaly_score(self, data: pd.DataFrame, building: str, config: dict) -> tuple[list, list, list, float]:
"""Calculates the anomaly score for the given data.
Args:
data: A dataframe containing a sensor data slice.
building: The name of the building from which the data originates
config: The user specified configuration data.
Returns:
The deep anomaly score if available, the calculated anomaly scores, the timestamps and the threshold.
"""
pass