local¶
Mode-dispatching TRIAD explainer (spec sections 7.1 and 11.1).
TriadExplainer accepts a fit_lgbm_gam result, a raw LightGBM booster,
or a fitted binary EBM, resolves exact vs approximate (SHAP) mode, and
produces TriadExplanation objects: a long channels frame, epistemic
scores (ES, ES_signed, KR), reason codes and waterfall plots.
TriadExplainer ¶
TriadExplainer(
model: Any,
*,
mode: str | None = None,
tau_method: str = "mom",
pair_split: str = "half",
lam: float = 1.0,
X_ref: DataFrame | None = None,
bag_boosters: tuple[Any, ...] | list[Any] | None = None
)
Decompose model predictions into I/D/M channels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Any
|
|
required |
mode
|
str | None
|
|
None
|
X_ref
|
DataFrame | None
|
Reference population: training data for bin counts (exact mode on a raw booster) and for the SHAP-mode tau^2 estimate. |
None
|
bag_boosters
|
tuple[Any, ...] | list[Any] | None
|
Bootstrap replicas providing epistemic variance in SHAP mode. |
None
|
Source code in src/triadxai/local.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
explain ¶
explain(X: DataFrame) -> TriadExplanation
Decompose the model score for each row of X.
Source code in src/triadxai/local.py
201 202 203 204 205 | |
TriadExplanation
dataclass
¶
TriadExplanation(
channels: DataFrame,
term_channels: DataFrame | None,
score: ndarray,
intercept: float,
mode: str,
approximate: bool,
)
Channel decomposition for a batch of instances.
epistemic_score ¶
epistemic_score() -> pd.DataFrame
Per-instance ES, ES_signed and knowledge ratio KR (spec 7.1).
Source code in src/triadxai/local.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
plot_waterfall ¶
plot_waterfall(i: int = 0, **kwargs: Any) -> Any
Three-channel waterfall for one instance (needs triadxai[viz]).
Source code in src/triadxai/local.py
66 67 68 69 70 | |
reasons ¶
reasons(
*,
orientation: str = "higher_is_better",
k: int = 4,
**kwargs: Any
) -> list[list[Any]]
Ranked, group-tagged adverse-action reasons per instance (spec 8).
Source code in src/triadxai/local.py
55 56 57 58 59 60 61 62 63 64 | |