attribution_disparity
from compileml.fairness import attribution_disparity
§6 — decompose the mean group score gap by feature, exactly.
The headline capability, and the reason this module is worth having in CompileML rather than taken from a general fairness library. Because the artifact's attribution reconciles to the score with a zero residual at depth ≤ 2, the per-feature contributions to a group gap **sum to the gap** — not approximately, exactly, in integer units.
A share above 100% is a real finding rather than an error: one driver widens the gap further than observed while others partially offset it. That statement is unavailable from a decomposition whose parts do not sum to the whole.
The group means are taken as exact rationals over integer sums, not as
floats. Float means of the same integers round differently depending on
how the sums happen to accumulate, which turned an exact identity into a
residual of ±1e-11 whose sign varied between machines. Here the residual
is 0.0 because it is zero, and the reported floats are conversions of
equal rationals, so mean_gap_half_micro == sum_of_feature_gaps holds
with ==.
Requires decide(..., include_contributions=True).
Parameters#
| Name | Type | Default | Kind |
|---|---|---|---|
| decisions | — | required | positional |
| protected | — | required | positional |
| feature_names | — | required | positional |
| labels | — | None | keyword-only |
Returns#
dict
Raises#
- ValueError
Read from the function body and the private helpers it calls, not inferred. A function that raises nothing has no section here.