class_docstr: A pure Python (slow) implementation of Tree SHAP.
      
class_docstr_tok: ["A","pure","Python","(","slow",")","implementation","of","Tree","SHAP","."]
code: def __init__(self, model, **kwargs):
      self.model_type = "internal"
  
      if str(type(model)).endswith(
          "sklearn.ensemble.forest.RandomForestRegressor'>"
      ):
          self.trees = [Tree(e.tree_) for e in model.estimators_]
      elif str(type(model)).endswith(
          "sklearn.ensemble.forest.RandomForestClassifier'>"
      ):
          self.trees = [
              Tree(e.tree_, normalize=True) for e in model.estimators_
          ]
      elif str(type(model)).endswith("xgboost.core.Booster'>"):
          self.model_type = "xgboost"
          self.trees = model
      elif str(type(model)).endswith("lightgbm.basic.Booster'>"):
          self.model_type = "lightgbm"
          self.trees = model
      else:
          raise ExplainerError(
              "Model type not supported by TreeExplainer: "
              + str(type(model))
          )
  
      if self.model_type == "internal":
          # Preallocate space for the unique path data
          maxd = np.max([t.max_depth for t in self.trees]) + 2
          s = (maxd * (maxd + 1)) // 2
          self.feature_indexes = np.zeros(s, dtype=np.int32)
          self.zero_fractions = np.zeros(s, dtype=np.float64)
          self.one_fractions = np.zeros(s, dtype=np.float64)
          self.pweights = np.zeros(s, dtype=np.float64)
  
file_path: shap/shap/explainers/pytree.py
imports: import numpy
  import pandas
  from ..utils._exceptions import ExplainerError
label_desc: Use image node_id 1 to create a new TreeExplainer object  with example: obj = TreeExplainer(model)