fatf.utils.metrics.subgroup_metrics.apply_metric_function(population_confusion_matrix: List[numpy.ndarray], metric_function: Callable[numpy.ndarray, float], *args, **kwargs) → List[float][source]

Applies the provided performance metric to every confusion matrix.

The performance metric function needs to take a numpy.ndarray confusion matrix as the first parameter followed by any number of unnamed and named parameters provided by *args and **kwargs parameters.


A list of confusion matrices for each sub-population.

metric_functionCallable[[numpy.ndarray], Number]

A metric function that takes a confusion matrix as a first parameter, followed by any number of unnamed parameters (*args) and any number of named parameters (**kwargs) and outputs a single number – the metric value.


Unnamed arguments passed to the metric function.


Named arguments passed to the metric function.


A list with the value of the selected metric for every sub-population.


The metric_function parameter does not require at least one unnamed parameter.


The confusion matrix is not a 2-dimensional numpy array, it is not square (equal width and height) or its dimension is not at least 2x2.


The confusion matrix is not of an integer kind (e.g. int, numpy.int32, numpy.int64). One of the metric_function outputs is not numerical. The metric_function is not Python callable. The population_confusion_matrix is not a list.


The confusion matrix is a structured numpy array. The population_confusion_matrix parameter is an empty list.