custom_disparity_metric
custom_disparity_metric#
- solas_disparity.disparity.custom_disparity_metric(...)#
Provide a modular format that to create a custom disparity metric.
- Parameters
group_data (DataFrame) – Dataframe containing columns for group data.
protected_groups (List[str]) – List of protected groups.
reference_groups (List[str]) – List of reference groups with the same length as
protected_groups
.group_categories (List[str]) – List of group categories to which each protected and reference group pair belongs to (e.g. race, gender, age, etc.). Has the same length as
protected_groups
.outcome (Series) – Outcome series.
metric (Callable[..., Union[int, float]]) – A function of an outcome, label, and/or sample weight that returns a scalar. Typical argument names such as those used by sklearn.metrics or SolasAI disparity testing functions.
label (Optional[Series], optional) – Label, true outcome, and/or target series evaluated alongside
outcome
. Defaults to None.sample_weight (Optional[Series], optional) – Sample weight series. Has the same length as
group_data
. Defaults to None.difference_calculation (Optional[ DifferenceCalculation ], optional) – Method for calculating the difference between group metrics. Defaults to DifferenceCalculation.REFERENCE_MINUS_PROTECTED.
difference_threshold (Optional[Callable[[Union[int, float]], bool]], optional) – A function of the difference between protected and reference group metrics that returns whether the difference is significant. This will be factored into practical significance if not
None
. Defaults to lambda difference:(difference < 0.0).ratio_calculation (Optional[ RatioCalculation ], optional) – Method for calculating the ratio between group metrics. Defaults to RatioCalculation.PROTECTED_OVER_REFERENCE.
ratio_threshold (Optional[Callable[[Union[int, float]], bool]], optional) – A function of the ratio between protected and reference group metrics that returns whether the difference is significant. This will be factored into practical significance if not
None
. Defaults to None.statistical_significance_test (Optional[StatSigTest], optional) – Statistical significance test that will be factored into practical significance if not
None
. Defaults to None.p_value_threshold (float, optional) – P-value threshold for statistical significance. Defaults to 0.05.
statistical_significance_arguments (Dict[str, Any], optional) – A dictionary of arbitrary arguments to the statistical significance test function. Every function corresponds to a member of
StatSigTest
. Defaults to dict().
- Returns
Object containing results of the disparity calculation.
- Return type