fatf.fairness.models.measures.disparate_impact

fatf.fairness.models.measures.disparate_impact(dataset: numpy.ndarray, ground_truth: numpy.ndarray, predictions: numpy.ndarray, column_index: Union[int, str], label_index: int = 0, groupings: Optional[List[Union[float, Tuple[str]]]] = None, numerical_bins_number: int = 5, treat_as_categorical: Optional[bool] = None, labels: Optional[List[Union[float, str]]] = None, tolerance: float = 0.2, criterion: Optional[str] = None) → Tuple[numpy.ndarray, List[str]][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).