You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3afe445
Browse filesBrowse the repository at this point in the historyBrowse files
authored
Fix path-dependent TreeSHAP dropping zero-cover subtrees entered by the explained point (#617)
* Fix path-dependent TreeSHAP dropping zero-cover subtrees entered by x
The edge tree computed each cover ratio as w_child / w_parent, which is 0/0
below a zero-cover node. QuadratureTreeSHAP then clamped the resulting NaN to
a 1e-300 cover and treated the subtree as unreachable. That is wrong when the
explained point's routing enters the zero-cover node (NaN default routing,
out-of-range values; common in CatBoost's oblivious trees) and a feature split
below it is absent. Attributions came out wrong, and constant trees got
nonzero Shapley values, violating the null-player axiom.
A zero-cover node now splits its (zero) mass equally between its children, so
the split weights at every node still sum to one. Edges into a zero-cover node
keep ratio 0 and the existing c -> 0 limit. The Python reference converter
mirrors the convention. The change covers QuadratureTreeSHAP at every order
and index. LinearTreeSHAP still refuses zero-cover trees by design.
Regression tests compare against a brute-force path-dependent game (SV and
k-SII) on a hand-built tree and on the CatBoost model of the report, check the
null-player axiom, and check that NaN XGBoost/LightGBM models and a CatBoost
classifier don't regress.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0125eRFMU1m2QrufYkqwogbZ
* Link PR in CHANGELOG entry
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0125eRFMU1m2QrufYkqwogbZ
* Restore the zero-cover comment in QuadratureTreeSHAP after the main merge
The merge of main brought back the pre-fix comment, which called zero-cover
subtrees unreachable and said p_e is NaN inside them. Neither holds anymore:
the edge tree now splits a zero-cover node's mass equally.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0125eRFMU1m2QrufYkqwogbZ
* Add note on CatBoost
* Add CatBoost Comment to AGENTS.md
---------
Co-authored-by: Maximilian Muschalik <noreply@anthropic.com>
Co-authored-by: Advueu963 <S.Thies@campus.lmu.de>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@
27
27
28
28
### Bugfix
29
29
30
+
- fixes path-dependent `TreeExplainer`/`QuadratureTreeSHAP` dropping the mass of a zero-cover subtree whenever the explained point's routing enters it (e.g. through NaN default routing or a value outside the training range, which is common in CatBoost's oblivious trees). Below such a node the cover ratio was `0/0` and the subtree was treated as unreachable, which gave wrong Shapley values and interactions and nonzero attributions on constant trees (violating the null-player axiom); efficiency was unaffected. A zero-cover node now splits its (zero) mass equally among its children, so its split weights still sum to one. [#617](https://github.com/mmschlk/shapiq/pull/617)
30
31
-`InterventionalTreeSHAPIQ(weight_fn=...)` dropped the terms whose interaction size equals `|E| + |R|`, so custom weights never reproduced a built-in index.
31
32
-`TreeExplainer` with `class_index=0` on binary gradient boosting classifiers (scikit-learn `GradientBoostingClassifier` and `HistGradientBoostingClassifier`, `XGBClassifier`, `LGBMClassifier`, `CatBoostClassifier`) silently returned the class-1 explanation in both `mode="pathdependent"` and `mode="interventional"`, including the Woodelf fast path. It now explains the class-0 log-odds, which are the negated class-1 log-odds: the values and the `baseline_value` are the negation of the `class_index=1` explanation. `class_index=None` still explains class 1.
32
33
-`TreeExplainer` with `class_index=None` on a multiclass LightGBM model explained the sum of the raw margins of all classes; it now explains class 1, like for the other libraries.
// splits[0] (CatBoost's first split chosen in training) becomes the root.
490
+
// This choice is made consistently with other tree models, but not with CatBoost's own ShapValues, which walk the levels in reverse.
491
+
// Both are exact for their order, but path-dependent SHAP values depend on the order of the splits. Interventional does not depend on the order of the splits, so it is consistent with CatBoost's own ShapValues.
0 commit comments