Interfaces
EvalInterface
Bases: object
The EvalInterface is an abstract base class that defines the interface for evaluation metrics in a generic evaluation system. It serves as a blueprint for concrete evaluation metric classes that implement specific evaluation logic.
Methods:
Name | Description |
---|---|
- calc |
Abstract method that calculates the evaluation metric based on the provided scores, labels, and margins parameters. It returns an instance of a class that inherits from MetricInterface. |
- get_name |
Abstract method that returns the name of the evaluation metric. Concrete classes implementing this interface should provide their own implementation of this method. |
calc
abstractmethod
calc(scores, labels, margins)
Calculates the evaluation metric based on the provided scores, labels, and margins.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scores |
ndarray
|
An array of anomaly scores. |
required |
labels |
ndarray
|
An array of ground truth labels. |
required |
margins |
[int(margin - before - anomaly), int(margin - after - anomaly)]
|
You can use margin to prune your evaluations if needed. Defined in https://github.com/dawnvince/EasyTSAD/blob/main/EasyTSAD/Controller/GlobalCfg.toml. |
required |
Returns:
Name | Type | Description |
---|---|---|
MetricInterface |
Type[MetricInterface]
|
An instance of the event detection metric. |
MetricInterface
Bases: object
The MetricInterface class is an abstract base class that defines the interface for metrics. It serves as a blueprint for creating subclasses that represent specific metrics.
The class includes three abstract methods: add(), avg(), and to_dict(). Subclasses inheriting from this class must implement these methods according to their specific metric calculations and requirements.
You should implement the following methods:
- add(self, other_metric): This abstract method represents the operation of combining two metrics. It takes another metric object (other_metric) as a parameter and is responsible for adding its values to the current metric.
- avg(self): This abstract method calculates the average value of the metric. It should be implemented by subclasses to compute the average based on the accumulated values.
- to_dict(self): This abstract method converts the metric object into a dictionary representation. It should return a dictionary containing the metric's values and any additional information needed for representation or storage.
add
abstractmethod
add(other_metric)
This abstract method represents the operation of combining two metrics. It takes another metric object (other_metric) as a parameter and is responsible for adding its values to the current metric.
avg
abstractmethod
avg()
This abstract method calculates the average value of the metric. It should be implemented by subclasses to compute the average based on the accumulated values.
to_dict
abstractmethod
to_dict()
This abstract method converts the metric object into a dictionary representation. It should return a dictionary containing the metric's values and any additional information needed for representation or storage.