MODULE REFERENCE

utils

anomx.metrics.utils

Metric Utils

classification_support

classification_support(func) -> Callable[..., METRIC_OUTPUT_TYPE]

This decorator adds support for classification metrics including sanity checks and handling of class probabilities and categorical samples.

Signature parameters
ParameterTypeDefault
func—required

Returns Callable[..., METRIC_OUTPUT_TYPE]

interval_support

interval_support(func) -> Callable[..., METRIC_OUTPUT_TYPE]

This decorator adds support for quantile interval metrics with sanity checks, processing, and extraction of quantiles from the intervals.

Signature parameters
ParameterTypeDefault
func—required

Returns Callable[..., METRIC_OUTPUT_TYPE]

multi_ts_support

multi_ts_support(func) -> Callable[..., METRIC_OUTPUT_TYPE]

This decorator further adapts the metrics that took as input two (or three for scaled metrics with insample) univariate/multivariate TimeSeries instances, adding support for equally-sized sequences of TimeSeries instances. The decorator computes the pairwise metric for TimeSeries with the same indices, and returns a float value that is computed as a function of all the pairwise metrics using a series_reduction subroutine passed as argument to the metric function.

If a 'Sequence[TimeSeries]' is passed as input, this decorator provides also parallelisation of the metric evaluation regarding different TimeSeries (if the n_jobs parameter is not set 1).

Signature parameters
ParameterTypeDefault
func—required

Returns Callable[..., METRIC_OUTPUT_TYPE]

multivariate_support

multivariate_support(func) -> Callable[..., METRIC_OUTPUT_TYPE]

This decorator transforms a metric function that takes as input two univariate TimeSeries instances into a function that takes two equally-sized multivariate TimeSeries instances, computes the pairwise univariate metrics for components with the same indices, and returns a float value that is computed as a function of all the univariate metrics using a component_reduction subroutine passed as argument to the metric function.

Signature parameters
ParameterTypeDefault
func—required

Returns Callable[..., METRIC_OUTPUT_TYPE]

register_metric_callback

register_metric_callback(callback: Callable) -> None

Register a callback to be invoked after every top-level metric call.

Signature parameters
ParameterTypeDefault
callbackCallablerequired

Returns None

unregister_metric_callback

unregister_metric_callback(callback: Callable) -> None

Remove a previously registered metric callback, if present.

Signature parameters
ParameterTypeDefault
callbackCallablerequired

Returns None

COMP_AX

COMP_AX = 1

METRIC_OUTPUT_TYPE

METRIC_OUTPUT_TYPE = float | list[float] | np.ndarray | list[np.ndarray]

METRIC_TYPE

METRIC_TYPE = Callable[..., METRIC_OUTPUT_TYPE]

PROBA_SUFFIX

PROBA_SUFFIX = '_p'

SMPL_AX

SMPL_AX = 2

TIME_AX

TIME_AX = 0