docstr: Builds the SHAP kernel explainer
  See https://shap.readthedocs.io/en/latest/#shap.KernelExplainer for additional details
  
  Args:
      training_data (numpy.array or pandas.DataFrame or shap.common.DenseData or
          any scipy.sparse matrix): The background dataset to use for integrating
          out features. In other words, the training data for the SHAP explainer
      predict_fn (Callable): User supplied function that takes a matrix of samples
          (# samples x # features) and computes a the output of the model for those samples.
          The output can be a vector (# samples) or a matrix (# samples x # model outputs).
      feature_names (list): List of feature names corresponding to the data
  
  Returns:
      None
docstr_tok: ["Builds","the","SHAP","kernel","explainer","See","https",":","\/\/shap.readthedocs.io\/en\/latest\/","#","shap.KernelExplainer","for","additional","details","Args",":","training_data","(","numpy.array","or","pandas.DataFrame","or","shap.common.DenseData","or","any","scipy.sparse","matrix",")",":","The","background","dataset","to","use","for","integrating","out","features",".","In","other","words",",","the","training","data","for","the","SHAP","explainer","predict_fn","(","Callable",")",":","User","supplied","function","that","takes","a","matrix","of","samples","(","#","samples","x","#","features",")","and","computes","a","the","output","of","the","model","for","those","samples",".","The","output","can","be","a","vector","(","#","samples",")","or","a","matrix","(","#","samples","x","#","model","outputs",")",".","feature_names","(","list",")",":","List","of","feature","names","corresponding","to","the","data","Returns",":","None"]
code: def build_explainer(
      self,
      training_data: Any,
      predict_fn: Callable,
      feature_names: List[str] = None,
      **kwargs,
  ):
      """
      Builds the SHAP kernel explainer
      See https://shap.readthedocs.io/en/latest/#shap.KernelExplainer for additional details
  
      Args:
          training_data (numpy.array or pandas.DataFrame or shap.common.DenseData or
              any scipy.sparse matrix): The background dataset to use for integrating
              out features. In other words, the training data for the SHAP explainer
          predict_fn (Callable): User supplied function that takes a matrix of samples
              (# samples x # features) and computes a the output of the model for those samples.
              The output can be a vector (# samples) or a matrix (# samples x # model outputs).
          feature_names (list): List of feature names corresponding to the data
  
      Returns:
          None
      """
      # Convert feature_names to a list if not None (in case it's a np.ndarray)
      if feature_names is not None:
          feature_names = list(feature_names)
      self.feature_names = feature_names
      self.predict_fn = predict_fn
      self.explainer_object = shap.KernelExplainer(
          model=predict_fn, data=training_data
      )
  
file_path: contextual-ai/xai/explainer/tabular/shap_tabular_explainer.py
imports: import warnings
  import dill
  import numpy
  import shap
  from typing import Optional, Callable, Any, List, Dict
  from xai.explainer.abstract_explainer import AbstractExplainer
  from xai.explainer.explainer_exceptions import ExplainerUninitializedError
  from xai.explainer.utils import parse_shap_values
label_desc: Use image node_id 2 for calling the SHAPTabularExplainer obj's underlying member method code with example usage: obj.build_explainer(training_data, predict_fn, feature_names) without return types