shapiq.tree.TreeSHAPIQΒΆ
- class shapiq.tree.TreeSHAPIQ(model, *, max_order=2, min_order=1, index='k-SII', verbose=False)[source]ΒΆ
Bases:
objectThe TreeSHAP-IQ computation class.
This class implements the TreeSHAP-IQ algorithm for computing Shapley Interaction values for tree-based models. It is used internally by the
TreeExplainer. The TreeSHAP-IQ algorithm is presented in Muschalik et al. (2024) [Mus24].TreeSHAP-IQ is an algorithm for computing Shapley Interaction values for tree-based models. It is based on the Linear TreeSHAP algorithm by Yu et al. (2022) [Yu22], but extended to compute Shapley Interaction values up to a given order. TreeSHAP-IQ needs to visit each node only once and makes use of polynomial arithmetic to compute the Shapley Interaction values efficiently.
Note
This class is not intended to be used directly. Instead, use the
TreeExplainerclass to explain tree-based models which internally uses then the TreeSHAP-IQ algorithm.Initializes the TreeSHAP-IQ explainer.
- Parameters:
model (
dict|TreeModel|Any) β A single tree model to explain. Note that unlike theTreeExplainerclass, TreeSHAP-IQ only supports a single tree. It can be a dictionary representation of the tree, aTreeModelobject, or any other single tree model supported by thevalidate_tree_model()function.max_order (
int) β The maximum interaction order to be computed. An interaction order of1corresponds to the Shapley value. Any value higher than1computes the Shapley interaction values up to that order. Defaults to2.min_order (
int) β The minimum interaction order to be computed. Must be>= 1. Defaults to1.index (
Literal['SV','SII','k-SII']) β The type of interaction to be computed.verbose (
bool) β Whether to print information about the tree during initialization. Defaults toFalse.