class_docstr: Kernel SHAP is a method that uses the LIME framework to compute
  Shapley Values. Setting the loss function, weighting kernel and
  regularization terms appropriately in the LIME framework allows
  theoretically obtaining Shapley Values more efficiently than
  directly computing Shapley Values.
  
  More information regarding this method and proof of equivalence
  can be found in the original paper here:
  https://arxiv.org/abs/1705.07874
class_docstr_tok: ["Kernel","SHAP","is","a","method","that","uses","the","LIME","framework","to","compute","Shapley","Values",".","Setting","the","loss","function",",","weighting","kernel","and","regularization","terms","appropriately","in","the","LIME","framework","allows","theoretically","obtaining","Shapley","Values","more","efficiently","than","directly","computing","Shapley","Values",".","More","information","regarding","this","method","and","proof","of","equivalence","can","be","found","in","the","original","paper","here",":","https",":","\/\/arxiv.org\/abs\/1705.07874"]
code: def kernel_shap_similarity_kernel(
      self, _, __, interpretable_sample: Tensor, **kwargs
  ) -> Tensor:
      assert (
          "num_interp_features" in kwargs
      ), "Must provide num_interp_features to use default similarity kernel"
      num_selected_features = int(
          interpretable_sample.sum(dim=1).item()
      )
      num_features = kwargs["num_interp_features"]
      if (
          num_selected_features == 0
          or num_selected_features == num_features
      ):
          # weight should be theoretically infinite when
          # num_selected_features = 0 or num_features
          # enforcing that trained linear model must satisfy
          # end-point criteria. In practice, it is sufficient to
          # make this weight substantially larger so setting this
          # weight to 1000000 (all other weights are 1).
          similarities = self.inf_weight
      else:
          similarities = 1.0
      return torch.tensor([similarities])
  
file_path: captum/captum/attr/_core/kernel_shap.py
imports: from typing import Any, Callable, Generator, Tuple, Union
  import torch
  from captum._utils.models.linear_model import SkLearnLinearRegression
  from captum._utils.typing import BaselineType, TargetType, TensorOrTupleOfTensorsGeneric
  from captum.attr._core.lime import construct_feature_mask, Lime
  from captum.attr._utils.common import _format_input_baseline
  from captum.log import log_usage
  from torch import Tensor
  from torch.distributions.categorical import Categorical
label_desc: Use image node_id 3 for calling the KernelShap obj's underlying member method code with example usage: obj.kernel_shap_similarity_kernel(_, __, interpretable_sample) and returns: torch