class_docstr: Uses Tree SHAP algorithms to explain the output of ensemble tree models.
  
  Tree SHAP is a fast and exact method to estimate SHAP values for tree models and ensembles of trees,
  under several different possible assumptions about feature dependence. It depends on fast C++
  implementations either inside an external model package or in the local compiled C extension.
class_docstr_tok: ["Uses","Tree","SHAP","algorithms","to","explain","the","output","of","ensemble","tree","models",".","Tree","SHAP","is","a","fast","and","exact","method","to","estimate","SHAP","values","for","tree","models","and","ensembles","of","trees",",","under","several","different","possible","assumptions","about","feature","dependence",".","It","depends","on","fast","C++","implementations","either","inside","an","external","model","package","or","in","the","local","compiled","C","extension","."]
code: def assert_additivity(self, phi, model_output):
      def check_sum(sum_val, model_output):
          diff = np.abs(sum_val - model_output)
          if np.max(diff / (np.abs(sum_val) + 1e-2)) > 1e-2:
              ind = np.argmax(diff)
              err_msg = (
                  "Additivity check failed in TreeExplainer! Please ensure the data matrix you passed to the "
                  "explainer is the same shape that the model was trained on. If your data shape is correct "
                  "then please report this on GitHub."
              )
              if self.feature_perturbation != "interventional":
                  err_msg += " Consider retrying with the feature_perturbation='interventional' option."
              err_msg += (
                  " This check failed because for one of the samples the sum of the SHAP values"
                  " was {:f}, while the model output was {:f}. If this difference is acceptable"
                  " you can set check_additivity=False to disable this check.".format(
                      sum_val[ind], model_output[ind]
                  )
              )
              raise ExplainerError(err_msg)
  
      if isinstance(phi, list):
          for i in range(len(phi)):
              check_sum(
                  self.expected_value[i] + phi[i].sum(-1),
                  model_output[:, i],
              )
      else:
          check_sum(self.expected_value + phi.sum(-1), model_output)
  
imports: import json
  import os
  import struct
  import time
  import warnings
  import numpy
  import pandas
  import scipy.sparse
  import scipy.special
  from packaging import version
  from ..None import maskers
  from .._explanation import Explanation
  from ..utils import assert_import, record_import_error, safe_isinstance
  from ..utils._exceptions import DimensionError, ExplainerError, InvalidFeaturePerturbationError, InvalidMaskerError, InvalidModelError
  from ..utils._legacy import DenseData
  from ._explainer import Explainer
label_desc: Use image node_id 9 for calling the TreeExplainer obj's underlying member method code with example usage: obj.assert_additivity(phi, model_output) without return types