class_docstr: Uses the Kernel SHAP method to explain the output of any function.
  
  Kernel SHAP is a method that uses a special weighted linear regression
  to compute the importance of each feature. The computed importance values
  are Shapley values from game theory and also coefficients from a local linear
  regression.
  
  Parameters
  ----------
  model : function or iml.Model
      User supplied function that takes a matrix of samples (# samples x # features) and
      computes the output of the model for those samples. The output can be a vector
      (# samples) or a matrix (# samples x # model outputs).
  
  data : numpy.array or pandas.DataFrame or shap.common.DenseData or any scipy.sparse matrix
      The background dataset to use for integrating out features. To determine the impact
      of a feature, that feature is set to "missing" and the change in the model output
      is observed. Since most models aren't designed to handle arbitrary missing data at test
      time, we simulate "missing" by replacing the feature with the values it takes in the
      background dataset. So if the background dataset is a simple sample of all zeros, then
      we would approximate a feature being missing by setting it to zero. For small problems,
      this background dataset can be the whole training set, but for larger problems consider
      using a single reference value or using the ``kmeans`` function to summarize the dataset.
      Note: for the sparse case, we accept any sparse matrix but convert to lil format for
      performance.
  
  feature_names : list
      The names of the features in the background dataset. If the background dataset is
      supplied as a pandas.DataFrame, then ``feature_names`` can be set to ``None`` (default),
      and the feature names will be taken as the column names of the dataframe.
  
  link : "identity" or "logit"
      A generalized linear model link to connect the feature importance values to the model
      output. Since the feature importance values, phi, sum up to the model output, it often makes
      sense to connect them to the output with a link function where link(output) = sum(phi).
      Default is "identity" (a no-op).
      If the model output is a probability, then "logit" can be used to transform the SHAP values
      into log-odds units.
  
  Examples
  --------
  See :ref:`Kernel Explainer Examples <kernel_explainer_examples>`.
class_docstr_tok: ["Uses","the","Kernel","SHAP","method","to","explain","the","output","of","any","function",".","Kernel","SHAP","is","a","method","that","uses","a","special","weighted","linear","regression","to","compute","the","importance","of","each","feature",".","The","computed","importance","values","are","Shapley","values","from","game","theory","and","also","coefficients","from","a","local","linear","regression",".","Parameters","--","--","--","--","--","model",":","function","or","iml.Model","User","supplied","function","that","takes","a","matrix","of","samples","(","#","samples","x","#","features",")","and","computes","the","output","of","the","model","for","those","samples",".","The","output","can","be","a","vector","(","#","samples",")","or","a","matrix","(","#","samples","x","#","model","outputs",")",".","data",":","numpy.array","or","pandas.DataFrame","or","shap.common.DenseData","or","any","scipy.sparse","matrix","The","background","dataset","to","use","for","integrating","out","features",".","To","determine","the","impact","of","a","feature",",","that","feature","is","set","to","``","missing","''","and","the","change","in","the","model","output","is","observed",".","Since","most","models","are","n't","designed","to","handle","arbitrary","missing","data","at","test","time",",","we","simulate","``","missing","''","by","replacing","the","feature","with","the","values","it","takes","in","the","background","dataset",".","So","if","the","background","dataset","is","a","simple","sample","of","all","zeros",",","then","we","would","approximate","a","feature","being","missing","by","setting","it","to","zero",".","For","small","problems",",","this","background","dataset","can","be","the","whole","training","set",",","but","for","larger","problems","consider","using","a","single","reference","value","or","using","the","``","kmeans","``","function","to","summarize","the","dataset",".","Note",":","for","the","sparse","case",",","we","accept","any","sparse","matrix","but","convert","to","lil","format","for","performance",".","feature_names",":","list","The","names","of","the","features","in","the","background","dataset",".","If","the","background","dataset","is","supplied","as","a","pandas.DataFrame",",","then","``","feature_names","``","can","be","set","to","``","None","``","(","default",")",",","and","the","feature","names","will","be","taken","as","the","column","names","of","the","dataframe",".","link",":","``","identity","''","or","``","logit","''","A","generalized","linear","model","link","to","connect","the","feature","importance","values","to","the","model","output",".","Since","the","feature","importance","values",",","phi",",","sum","up","to","the","model","output",",","it","often","makes","sense","to","connect","them","to","the","output","with","a","link","function","where","link","(","output",")","=","sum","(","phi",")",".","Default","is","``","identity","''","(","a","no-op",")",".","If","the","model","output","is","a","probability",",","then","``","logit","''","can","be","used","to","transform","the","SHAP","values","into","log-odds","units",".","Examples","--","--","--","--","See",":","ref",":","`","Kernel","Explainer","Examples","<","kernel_explainer_examples",">","`","."]
code: def run(self):
      num_to_run = (
          self.nsamplesAdded * self.N - self.nsamplesRun * self.N
      )
      data = self.synth_data[
          self.nsamplesRun * self.N : self.nsamplesAdded * self.N, :
      ]
      if self.keep_index:
          index = self.synth_data_index[
              self.nsamplesRun * self.N : self.nsamplesAdded * self.N
          ]
          index = pd.DataFrame(index, columns=[self.data.index_name])
          data = pd.DataFrame(data, columns=self.data.group_names)
          data = pd.concat([index, data], axis=1).set_index(
              self.data.index_name
          )
          if self.keep_index_ordered:
              data = data.sort_index()
      modelOut = self.model.f(data)
      if isinstance(modelOut, (pd.DataFrame, pd.Series)):
          modelOut = modelOut.values
      self.y[
          self.nsamplesRun * self.N : self.nsamplesAdded * self.N, :
      ] = np.reshape(modelOut, (num_to_run, self.D))
  
      # find the expected value of each output
      for i in range(self.nsamplesRun, self.nsamplesAdded):
          eyVal = np.zeros(self.D)
          for j in range(0, self.N):
              eyVal += self.y[i * self.N + j, :] * self.data.weights[j]
  
          self.ey[i, :] = eyVal
          self.nsamplesRun += 1
  
imports: import copy
  import gc
  import itertools
  import logging
  import time
  import warnings
  import numpy
  import pandas
  import scipy.sparse
  import sklearn
  from packaging import version
  from scipy.special import binom
  from sklearn.linear_model import Lasso, LassoLarsIC, lars_path
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import StandardScaler
  from tqdm.auto import tqdm
  from .._explanation import Explanation
  from ..utils import safe_isinstance
  from ..utils._exceptions import DimensionError
  from ..utils._legacy import DenseData, SparseData, convert_to_data, convert_to_instance, convert_to_instance_with_index, convert_to_link, convert_to_model, match_instance_to_data, match_model_to_data
  from ._explainer import Explainer
label_desc: Use image node_id 9 for calling the KernelExplainer obj's underlying member method code with example usage: obj.run() without return types