Examples · Plots

band_conditioned_decision_drivers

Drivers conditioned on the band, which is what a reviewer actually asks: what puts people in G09?

Code#

band_conditioned_decision_drivers.py
import matplotlib.pyplot as plt
 
from _setup import X_test, artifact, y_test
 
from compileml.runtime import decide
from compileml.viz import band_conditioned_decision_drivers
 
# 1,500 rather than a few hundred: this plot splits the sample ten ways,
# and sixty accounts per panel is not enough to read a driver from.
sample = X_test[:1500]
decisions = [decide(artifact, r.tolist(), include_contributions=True) for r in sample]
 
fig, axes = band_conditioned_decision_drivers(decisions, y=y_test[:1500], top_codes=6)
fig.savefig(
"../../public/examples/band_conditioned_decision_drivers.png",
dpi=110,
bbox_inches="tight",
)
plt.close(fig)
 
bands = {}
for decision in decisions:
bands[decision["band"]] = bands.get(decision["band"], 0) + 1
 
print("decisions per band:")
for band in sorted(bands):
print(f" {band} {bands[band]:>4}")
print()
print("A code that dominates the worst band may be absent from the best one.")
print("Pooling every decision together hides that.")

Output#

Captured from an actual run against compileml 0.9.0 and the UCI credit panel. If this script stops working, the build fails.

captured in CIband_conditioned_decision_drivers.py
decisions per band:
G01 148
G02 168
G03 143
G04 144
G05 159
G06 149
G07 148
G08 132
G09 136
G10 173
 
A code that dominates the worst band may be absent from the best one.
Pooling every decision together hides that.

Figure#

Output of the band_conditioned_decision_drivers example

Rendered by the run above, from the decision payload rather than a recomputation.

Notes#

  • Exported under the shorter alias band_drivers as well.

API reference: band_conditioned_decision_drivers →