fatf.fairness.models.measures.disparate_impact

fatf.fairness.models.measures.disparate_impact(dataset, ground_truth, predictions, column_index, label_index=0, groupings=None, numerical_bins_number=5, treat_as_categorical=None, labels=None, tolerance=0.2, criterion=None)[source]

Calculates selected disparate impact grid for a data set.

This function combines fatf.utils.metrics.tools.confusion_matrix_per_subgroup function together with fatf.utils.metrics.subgroup_metrics.apply_metric function. For the description of parameters, errors and exceptions please see the documentation of these functions.

Parameters
dataset, ground_truth, predictions, column_index, groupings, numerical_bins_number, labels, and treat_as_categorical

See the documentation of fatf.utils.metrics.tools.confusion_matrix_per_subgroup function.

label_indexinteger

The index of the “positive” class in the confusion matrix. (Not required for binary problems.) See the description of fatf.utils.data.tools.group_by_column function.

criterionUnion[None, string]

A string representing group fairness criterion. One of: 'demographic parity', 'equal opportunity', 'equal accuracy' or None for the default option 'equal accuracy'.

tolerancenumber

A number between 0 and 1 that indicates how much any two metrics can differ to be considered “equal”.

Returns
disparity_gridnumpy.ndarray

A square, symmetric, boolean numpy array that indicates for which pair of sub-populations a disparity happens.

Raises
TypeError

The criterion parameter is neither None nor a string.

ValueError

The criterion parameter is none of the allowed values (see the description of the parameter).