docstr: Estimate the SHAP values for a sample
  
  Args:
      instance (np.ndarray): A 1D numpy array corresponding to a row/single example
      num_samples (int): The number of re-evaluations to conduct. The higher the samples,
          the lower the variance
      num_features (int): Number of features to include in an explanation
  
  Returns:
      (dict) A mapping of class to explanations
  
  Raises:
      ExplainerUninitializedError: Raised if self.explainer_object is None
docstr_tok: ["Estimate","the","SHAP","values","for","a","sample","Args",":","instance","(","np.ndarray",")",":","A","1D","numpy","array","corresponding","to","a","row\/single","example","num_samples","(","int",")",":","The","number","of","re-evaluations","to","conduct",".","The","higher","the","samples",",","the","lower","the","variance","num_features","(","int",")",":","Number","of","features","to","include","in","an","explanation","Returns",":","(","dict",")","A","mapping","of","class","to","explanations","Raises",":","ExplainerUninitializedError",":","Raised","if","self.explainer_object","is","None"]
code: def explain_instance(
      self,
      instance: np.ndarray,
      num_samples: Optional[int] = None,
      num_features: int = NUM_TOP_FEATURES,
      **kwargs,
  ) -> Dict[int, Dict]:
      """
      Estimate the SHAP values for a sample
  
      Args:
          instance (np.ndarray): A 1D numpy array corresponding to a row/single example
          num_samples (int): The number of re-evaluations to conduct. The higher the samples,
              the lower the variance
          num_features (int): Number of features to include in an explanation
  
      Returns:
          (dict) A mapping of class to explanations
  
      Raises:
          ExplainerUninitializedError: Raised if self.explainer_object is None
      """
      if num_samples is None:
          # Let SHAP figure out default number of samples
          num_samples = "auto"
          warnings.warn(
              message="SHAP default number of samples[{}]".format(
                  num_samples
              )
          )
  
      if self.explainer_object:
          if len(instance.shape) != 2:
              instance = instance.reshape([1, -1])
  
          confidences = list(
              np.array(self.predict_fn(instance)).ravel()
          )
  
          explanation = self.explainer_object.shap_values(
              X=instance,
              nsamples=num_samples,
              l1_reg="num_features({})".format(NUM_TOP_FEATURES),
          )
          return parse_shap_values(
              shap_values=explanation,
              confidences=confidences,
              feature_names=self.feature_names,
              feature_values=list(instance.ravel()),
          )
      else:
          raise ExplainerUninitializedError(
              "This explainer is not yet instantiated! "
              "Please call build_explainer()"
              "first before calling explain_instance."
          )
  
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 3 for calling the SHAPTabularExplainer obj's underlying member method code with example usage: obj.explain_instance(instance, num_samples, num_features) and returns: parse_shap_values