class_docstr: A pure Python (slow) implementation of Tree SHAP.
      
class_docstr_tok: ["A","pure","Python","(","slow",")","implementation","of","Tree","SHAP","."]
code: def tree_shap(
      self, tree, x, x_missing, phi, condition=0, condition_feature=0
  ):
      # update the bias term, which is the last index in phi
      # (note the paper has this as phi_0 instead of phi_M)
      if condition == 0:
          phi[-1, :] += tree.values[0, :]
  
      # start the recursive algorithm
      tree_shap_recursive(
          tree.children_left,
          tree.children_right,
          tree.children_default,
          tree.features,
          tree.thresholds,
          tree.values,
          tree.node_sample_weight,
          x,
          x_missing,
          phi,
          0,
          0,
          self.feature_indexes,
          self.zero_fractions,
          self.one_fractions,
          self.pweights,
          1,
          1,
          -1,
          condition,
          condition_feature,
          1,
      )
  
file_path: shap/shap/explainers/pytree.py
imports: import numpy
  import pandas
  from ..utils._exceptions import ExplainerError
label_desc: Use image node_id 4 for calling the TreeExplainer obj's underlying member method code with example usage: obj.tree_shap(tree, x, x_missing, phi, condition, condition_feature) without return types