compileml.fairness

feature_swing

def feature_swing(artifact, X, protected, *, labels=None, max_rows: int = 400, seed: int = 7) -> dict

from compileml.fairness import feature_swing

§7 — how far each feature *can* move a score, per group.

An infinitesimal derivative is the wrong instrument here. A compiled artifact is piecewise constant, so a small perturbation returns zero almost everywhere and a gradient-style sensitivity measures nothing but whether a threshold happened to fall nearby.

What is meaningful for a step function is the **swing**: hold the rest of the row fixed, move one feature across the values the population actually takes, and record how far the score travels. Evaluated at the artifact's own split thresholds, so it is exact rather than sampled — the score between two thresholds is constant by construction.

Parameters#

NameTypeDefaultKind
artifact—requiredpositional
X—requiredpositional
protected—requiredpositional
labels—Nonekeyword-only
max_rowsint400keyword-only
seedint7keyword-only

Returns#

dict