class_docstr: Explanation wrapper for the `shap` package
  
  This object uses the shap package to create the model explanation.
  See ttps://github.com/slundberg/shap
  
  Parameters
  ----------
  type : {'predict_parts', 'model_parts'}
      Method type for calculations.
  
  Attributes
  ----------
  result : list or numpy.ndarray
      Calculated shap values for `new_observation` data.
  shap_explainer : {shap.TreeExplainer, shap.DeepExplainer, shap.GradientExplainer, shap.LinearExplainer, shap.KernelExplainer}
      Explainer object from the `shap` package.
  shap_explainer_type : {'TreeExplainer', 'DeepExplainer',
      'GradientExplainer', 'LinearExplainer', 'KernelExplainer'}
      String name of the Explainer class.
  new_observation : pandas.Series or pandas.DataFrame
      Observations for which the shap values will be calculated
      (later stored in `result`).
  type : {'predict_parts', 'model_parts'}
      Method type for calculations.
  
  Notes
  ----------
  - https://github.com/slundberg/shap
docstr: Calculate the result of explanation
  
  Fit method makes calculations in place and changes the attributes.
  
  Parameters
  -----------
  explainer : Explainer object
      Model wrapper created using the Explainer class.
  new_observation : pd.Series or np.ndarray
      An observation for which a prediction needs to be explained.
  shap_explainer_type : {'TreeExplainer', 'DeepExplainer', 'GradientExplainer', 'LinearExplainer', 'KernelExplainer'}
      String name of the Explainer class (default is `None`, which automatically
      chooses an Explainer to use).
  kwargs: dict
      Keyword parameters passed to the `shapley_values` method.
  
  Returns
  -----------
  None
docstr_tok: ["Calculate","the","result","of","explanation","Fit","method","makes","calculations","in","place","and","changes","the","attributes",".","Parameters","--","--","--","--","--","-","explainer",":","Explainer","object","Model","wrapper","created","using","the","Explainer","class",".","new_observation",":","pd.Series","or","np.ndarray","An","observation","for","which","a","prediction","needs","to","be","explained",".","shap_explainer_type",":","{","'TreeExplainer","'",",","'DeepExplainer","'",",","'GradientExplainer","'",",","'LinearExplainer","'",",","'KernelExplainer","'","}","String","name","of","the","Explainer","class","(","default","is","`","None","`",",","which","automatically","chooses","an","Explainer","to","use",")",".","kwargs",":","dict","Keyword","parameters","passed","to","the","`","shapley_values","`","method",".","Returns","--","--","--","--","--","-","None"]
code: def fit(
      self,
      explainer,
      new_observation,
      shap_explainer_type=None,
      **kwargs,
  ):
      """Calculate the result of explanation
  
      Fit method makes calculations in place and changes the attributes.
  
      Parameters
      -----------
      explainer : Explainer object
          Model wrapper created using the Explainer class.
      new_observation : pd.Series or np.ndarray
          An observation for which a prediction needs to be explained.
      shap_explainer_type : {'TreeExplainer', 'DeepExplainer', 'GradientExplainer', 'LinearExplainer', 'KernelExplainer'}
          String name of the Explainer class (default is `None`, which automatically
          chooses an Explainer to use).
      kwargs: dict
          Keyword parameters passed to the `shapley_values` method.
  
      Returns
      -----------
      None
      """
      from shap import (
          TreeExplainer,
          DeepExplainer,
          GradientExplainer,
          LinearExplainer,
          KernelExplainer,
      )
  
      checks.check_compatibility(explainer)
      shap_explainer_type = checks.check_shap_explainer_type(
          shap_explainer_type, explainer.model
      )
  
      if self.type == "predict_parts":
          new_observation = checks.check_new_observation_predict_parts(
              new_observation, explainer
          )
  
      if shap_explainer_type == "TreeExplainer":
          try:
              self.shap_explainer = TreeExplainer(
                  explainer.model, explainer.data.values
              )
          except:  # https://github.com/ModelOriented/DALEX/issues/371
              self.shap_explainer = TreeExplainer(explainer.model)
      elif shap_explainer_type == "DeepExplainer":
          self.shap_explainer = DeepExplainer(
              explainer.model, explainer.data.values
          )
      elif shap_explainer_type == "GradientExplainer":
          self.shap_explainer = GradientExplainer(
              explainer.model, explainer.data.values
          )
      elif shap_explainer_type == "LinearExplainer":
          self.shap_explainer = LinearExplainer(
              explainer.model, explainer.data.values
          )
      elif shap_explainer_type == "KernelExplainer":
          self.shap_explainer = KernelExplainer(
              lambda x: explainer.predict(x), explainer.data.values
          )
  
      self.result = self.shap_explainer.shap_values(
          new_observation.values, **kwargs
      )
      self.new_observation = new_observation
      self.shap_explainer_type = shap_explainer_type
  
file_path: DALEX/python/dalex/dalex/wrappers/_shap/object.py
imports: import numpy
  from .None import checks
  from ..._explanation import Explanation
label_desc: Use image node_id 2 for calling the ShapWrapper obj's underlying member method code with example usage: obj.fit(explainer, new_observation, shap_explainer_type) without return types