ExFairness.Detection.DisparateImpact (ExFairness v0.5.1)

View Source

Disparate Impact detection using the 80% rule (4/5ths rule).

The 80% rule is a legal guideline from the EEOC (Equal Employment Opportunity Commission) used to determine if there is adverse impact in employment decisions.

The 80% Rule

A selection rate for any group that is less than 80% (4/5ths) of the rate for the group with the highest selection rate is generally regarded as evidence of adverse impact.

Ratio = (Selection Rate for Group with Lower Rate) / (Selection Rate for Group with Higher Rate)

If Ratio ≥ 0.8, the process passes the 80% rule. If Ratio < 0.8, there may be disparate impact.

This is a legal standard, not just a statistical measure. It's used in:

  • Employment discrimination cases (hiring, promotion, termination)
  • Lending decisions
  • Educational admissions
  • Housing decisions

Limitations

  • The 80% rule is a guideline, not an absolute legal requirement
  • Statistical significance should also be considered
  • Small sample sizes may produce unreliable ratios
  • Does not prove discrimination, only suggests further investigation

References

Examples

iex> predictions = Nx.tensor([1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0])
iex> sensitive = Nx.tensor([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
iex> result = ExFairness.Detection.DisparateImpact.detect(predictions, sensitive)
iex> result.passes_80_percent_rule
true

Summary

Functions

Detects disparate impact using the 80% rule.

Types

result()

@type result() :: %{
  group_a_rate: float(),
  group_b_rate: float(),
  ratio: float(),
  passes_80_percent_rule: boolean(),
  interpretation: String.t()
}

Functions

detect(predictions, sensitive_attr, opts \\ [])

@spec detect(Nx.Tensor.t(), Nx.Tensor.t(), keyword()) :: result()

Detects disparate impact using the 80% rule.

Parameters

  • predictions - Binary predictions tensor (0 or 1)
  • sensitive_attr - Binary sensitive attribute tensor (0 or 1)
  • opts - Options:
    • :min_per_group - Minimum samples per group for validation (default: 10)

Returns

A map containing:

  • :group_a_rate - Selection rate for group A
  • :group_b_rate - Selection rate for group B
  • :ratio - Disparate impact ratio (min rate / max rate)
  • :passes_80_percent_rule - Whether ratio ≥ 0.8
  • :interpretation - Plain language explanation

Examples

iex> predictions = Nx.tensor([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0])
iex> sensitive = Nx.tensor([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
iex> result = ExFairness.Detection.DisparateImpact.detect(predictions, sensitive)
iex> result.passes_80_percent_rule
false