Compound metrics

class dtaianomaly.evaluation.ThresholdMetric(thresholder: Thresholding, metric: BinaryMetric)[source]

Wrapper to combine a BinaryMetric object with some thresholding, to make sure that it can take continuous anomaly scores as an input. This is done by first applying some thresholding to the predicted anomaly scores, after which a binary metric can be computed.

Parameters:
  • thresholder (Thresholding) – Instance of the desired Thresholding class

  • metric (Metric) – Instance of the desired Metric class

class dtaianomaly.evaluation.BestThresholdMetric(metric: BinaryMetric, max_nb_thresholds: int = -1)[source]

Compute the maximum score of a binary metric over all thresholds. This method will iterate over the possible threshold for given predicted anomaly scores, compute the binary metric for each threshold, and then return the score for the highest threshold.

Parameters:
  • metric (BinaryMetric) – Instance of the desired Metric class

  • max_nb_thresholds (int, default=-1) – The maximum number of thresholds to use for computing the best threshold. If max_nb_thresholds = -1, all thresholds will be used. Otherwise, the value indicates the subsample of all possible thresholds that should be used. This subset is created by first sorting the possible unique thresholds, and then selecting the threshold at regular intervals (i.e., the 3rd, 6th, 9th, …). We recommend using the default value (use all thresholds), but can be used for reducing the resource requirements.

threshold_

The threshold resulting in the best performance.

Type:

float

thresholds_

The thresholds used for evaluating the performance.

Type:

array-like of floats

scores_

The evaluation scores corresponding to each threshold in thresholds_.

Type:

array-like of floats