shapiq.tree.LinearTreeSHAPΒΆ
- class shapiq.tree.LinearTreeSHAP(model, *, base_func=<function chebpts2>)[source]ΒΆ
Bases:
objectLinear TreeSHAP explainer for first-order Shapley values on tree-based models.
Implements the Linear TreeSHAP algorithm of Yu et al. (2022) for exact
order=1Shapley value computation on a single decision tree. The heavy lifting is delegated to a C++ kernel (linear_tree_shap_iterative), which is faster than the any-orderTreeSHAPIQalgorithm when only Shapley values are needed.- Variables:
clf β The original tree-based model passed by the user.
edge_tree β Edge-based representation of the tree (
EdgeTree) used by the C++ kernel for efficient traversal.N β The \(N'\) matrix used by Linear TreeSHAP (see
get_N_prime()).Base β The Chebyshev (or user-supplied) interpolation base of length
max_depth.Offset β The Vandermonde-style power cache of
Base + 1.N_v2 β The interpolation N matrix evaluated at
Base(seeget_N_v2()).
- Parameters:
model (Model)
base_func (Callable[[int], np.ndarray])
Initialize the
LinearTreeSHAPexplainer.- Parameters:
model (
Any) β A fitted single-tree model accepted byvalidate_tree_model().base_func (
Callable[[int],ndarray]) β Callableint -> np.ndarrayreturning the interpolation base for the given depth. Defaults tonumpy.polynomial.chebyshev.chebpts2().