Thresholding

class dtaianomaly.thresholding.Thresholding[source]

Base thresholding class.

A base class for converting continuous anomaly scores to discrete anomaly labels. This is useful for actually detecting anomalies, rather than just knowing how anomalous an instance is realtive to the other instances.

threshold(scores: ndarray) ndarray[source]

Threshold the given anomaly scores.

Apply the thresholding operation to the given anomaly scores. This function will perform the necessary checks and formatting on the anomaly scores, before effectively applying the thresholding.

Parameters:
scoresarray-like of shape (n_samples)

The continuous anomaly scores to convert to binary anomaly labels.

Returns:
array-like of shape (n_samples)

The discrete anomaly labels, in which a 0 indicates normal and a 1 indicates anomalous.

Raises:
ValueError

If scores is not a valid array

ValueError

If scores is not one-dimensional. If all dimensions but one have a size of 1, then no error will be thrown.