Skip to content

Model adapters

TriadExplainer accepts three kinds of model, resolving the mode at construction (decision 1):

Input Mode
a fit_lgbm_gam result exact
a raw LightGBM booster exact if additive and X_ref is given, else approximate (needs bag_boosters)
a fitted binary EBM exact

An explicit mode= overrides the inference; mode="exact" on a non-additive booster raises, while mode="shap" on an additive one is allowed (the two modes coincide there — decision 12).

LightGBM

fit_lgbm_gam is the flagship path: it fits a booster with interaction_constraints restricting every tree to a single feature — an additive model — plus bag replicas, and returns everything exact mode needs. It uses the native lgb.train API (not the sklearn wrapper) to avoid a scikit-learn dependency, and lightgbm is a core dependency so the default documented workflow works after a bare pip install triadxai (decision 6).

The adapter reconstructs each feature's shape function from dump_model(); the reconstruction reconciles with predict(raw_score=True) exactly. Caveats, recorded in decision 13:

  • init_score is rejected — it breaks score reconciliation.
  • zero_as_missing models are rejected (unsupported missing_type). With the default missing handling and no NaNs seen in training, missing values are routed as 0.0, matching LightGBM.
  • Exact mode is main-effects by construction — interacting boosters go through approximate mode; a multi-feature tree makes the adapter raise "booster is not additive".
  • Unseen categorical levels are routed to the unknown slot, whose value equals the missing-path value — mirroring what the pandas prediction pipeline does (unseen level → NaN code).
  • Numeric binning uses searchsorted(thresholds, x, side="left"), matching LightGBM's x <= thr → left split semantics.
  • fit_lgbm_gam requires a binary target in v0.1.

EBM (triadxai[ebm])

The EBM adapter reads fitted attributes only — term_scores_, standard_deviations_, bin_weights_, feature_bounds_ — so triadxai itself never imports interpret; the extra is needed to fit EBMs. Term tensors carry the missing bin at index 0 and the unknown bin at index −1 per axis; outer-bag SDs become the per-bin variance v and bin_weights_ the training mass n.

Findings verified against interpret 0.6.16 (decision 10):

  • the per-bin SD attribute is standard_deviations_, not term_standard_deviations_;
  • intercept_ is an ndarray of shape (1,) for binary classifiers, not a float;
  • out-of-range continuous values clamp to the terminal value bin, not the unknown bin;
  • standard_deviations_ becomes None after monotonize() — the adapter raises, since TRIAD needs outer-bag variances;
  • with outer_bags=1 the SDs are all zeros — the adapter warns that the D channel will be degenerate;
  • EBM's binning convention (searchsorted(cuts, x, side="right") + 1) differs from LightGBM's; the adapter reproduces eval_terms exactly.

Multiclass EBMs are not supported in v0.1; pair terms (interactions) are handled with the half-split described in channels and guarantees.

Roadmap

Scorecard and pyGAM adapters, a CatBoost SGLB fast-path, multiclass models and pair_split="pooled" are deferred to v0.2+ (decision 15).