Skip to content

Add tree/tabular model backend + enable SHAP TreeExplainer end-to-end #246

Description

@stanlrt

Summary

Add a tree/tabular model backend (sklearn / XGBoost / LightGBM) so SHAP TreeExplainer runs end-to-end. TreeExplainer is already registered but unusable: no backend loads a tree model, and it needs the raw fitted estimator, not an nn.Module.

Blocked by #209 (make the model-module explanation contract backend-agnostic). TreeExplainer needs structural access to the tree (splits, leaf values), which the current nn.Module-shaped explanation contract cannot express. The agnostic contract from #209 is the prerequisite.

What exists

  • MethodFamily.TREE defined — src/raitap/transparency/contracts.py:104
  • TreeExplainer registered in the SHAP adapter, tagged {SHAPLEY, TREE}src/raitap/transparency/explainers/shap_explainer.py:113
  • It carries a behavior-preserving placeholder requires=frozenset({Capability.AUTOGRAD}) — wrong capability, kept only because nothing provides TREE_MODEL yet
  • Capability.TREE_MODEL pre-seeded as a roadmap member, no provider/requirer yet — src/raitap/types.py
  • The image visualiser explicitly rejects it — src/raitap/transparency/tests/test_methods.py:74

Tasks (after #209 lands)

  1. Add a tree/tabular backend that declares @backends.register(provides=frozenset({Capability.TREE_MODEL})) (add PREDICT_PROBA if it exposes probabilities). See docs/contributor/adding-a-backend.md. It returns the fitted estimator through the agnostic explanation contract from Make the model-module explanation contract backend-agnostic (drop the nn.Module bridge) #209 (no nn.Module facade).
  2. Flip TreeExplainer from requires={AUTOGRAD} to requires={Capability.TREE_MODEL}. The capability gate then rejects it cleanly on torch/onnx (clear BackendIncompatibilityError) and routes it only to the tree backend.
  3. Reconcile the backend's __call__ / prediction semantics with the pipeline: tree models emit probabilities/labels, not logits, while the forward pass + argmax-predictions path assumes logits. Decide how predictions and metrics behave over tree outputs.
  4. Choose a suitable visualiser for tree attributions (the image visualiser rejects TreeExplainer today).

Acceptance criteria

  • TreeExplainer runs end-to-end on a real tree model via a documented tree backend.
  • requires reflects the true capability (TREE_MODEL, not the AUTOGRAD placeholder).
  • Selecting TreeExplainer on a non-tree backend raises a clear BackendIncompatibilityError, not a SHAP-internal failure.
  • Predictions/metrics behave sensibly for tree-model outputs.
  • Docs reflect the actually supported explainability methods + the new backend.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions