Examples · Bands

band_efficiency

Reading the refinable / exhausted / inconclusive verdict — how much separation is still on the table.

Code#

band_efficiency.py
from _setup import bands, latent, y_train
 
from compileml.bands import band_efficiency
 
report = band_efficiency(latent, y_train, bands)
 
print(f"continuous gini {report["continuous_gini"]}")
print(f"band-ordinal gini {report["band_ordinal_gini"]}")
print(f"gap {report["gini_gap"]} ({report["gini_gap_pct"]}%)")
print(f"worst band {report["worst_band"]}")
 
print()
print(f"{"band":<7}{"n":>7}{"bad rate":>11}{"within AUC":>12} verdict")
for entry in report["per_band"]:
print(
f"{entry["band"]:<7}{entry["n"]:>7}{entry["bad_rate"]:>11.4f}"
f"{entry["auc_within"]:>12.3f} {entry["verdict"]}"
)
 
print()
print("A band that can still separate outcomes is a refinement opportunity.")
print("A band that cannot is a band you have used up.")

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_efficiency.py
continuous gini 0.562
band-ordinal gini 0.5535
gap 0.0085 (1.52%)
worst band G09
 
band n bad rate within AUC verdict
G01 2161 0.0389 0.609 inconclusive
G02 2332 0.0759 0.557 inconclusive
G03 2157 0.0960 0.520 inconclusive
G04 2285 0.1247 0.510 exhausted
G05 2293 0.1273 0.523 inconclusive
G06 2242 0.1401 0.518 inconclusive
G07 2244 0.2130 0.544 inconclusive
G08 2234 0.2578 0.557 inconclusive
G09 2299 0.4241 0.589 refinable
G10 2253 0.7053 0.582 refinable
 
A band that can still separate outcomes is a refinement opportunity.
A band that cannot is a band you have used up.

Notes#

  • refinable: more bands would separate more risk. exhausted: the ladder already captures what the score knows. inconclusive: not enough data to say.

API reference: band_efficiency →