class_docstr: This method approximates the Shapley values by iterating through permutations of the inputs.
  
  This is a model agnostic explainer that guarantees local accuracy (additivity) by iterating completely
  through an entire permutation of the features in both forward and reverse directions (antithetic sampling).
  If we do this once, then we get the exact SHAP values for models with up to second order interaction effects.
  We can iterate this many times over many random permutations to get better SHAP value estimates for models
  with higher order interactions. This sequential ordering formulation also allows for easy reuse of
  model evaluations and the ability to efficiently avoid evaluating the model when the background values
  for a feature are the same as the current input value. We can also account for hierarchical data
  structures with partition trees, something not currently implemented for KernalExplainer or SamplingExplainer.
class_docstr_tok: ["This","method","approximates","the","Shapley","values","by","iterating","through","permutations","of","the","inputs",".","This","is","a","model","agnostic","explainer","that","guarantees","local","accuracy","(","additivity",")","by","iterating","completely","through","an","entire","permutation","of","the","features","in","both","forward","and","reverse","directions","(","antithetic","sampling",")",".","If","we","do","this","once",",","then","we","get","the","exact","SHAP","values","for","models","with","up","to","second","order","interaction","effects",".","We","can","iterate","this","many","times","over","many","random","permutations","to","get","better","SHAP","value","estimates","for","models","with","higher","order","interactions",".","This","sequential","ordering","formulation","also","allows","for","easy","reuse","of","model","evaluations","and","the","ability","to","efficiently","avoid","evaluating","the","model","when","the","background","values","for","a","feature","are","the","same","as","the","current","input","value",".","We","can","also","account","for","hierarchical","data","structures","with","partition","trees",",","something","not","currently","implemented","for","KernalExplainer","or","SamplingExplainer","."]
docstr: Legacy interface to estimate the SHAP values for a set of samples.
  
  Parameters
  ----------
  X : numpy.array or pandas.DataFrame or any scipy.sparse matrix
      A matrix of samples (# samples x # features) on which to explain the model's output.
  
  npermutations : int
      Number of times to cycle through all the features, re-evaluating the model at each step.
      Each cycle evaluates the model function 2 * (# features + 1) times on a data matrix of
      (# background data samples) rows. An exception to this is when PermutationExplainer can
      avoid evaluating the model because a feature's value is the same in X and the background
      dataset (which is common for example with sparse features).
  
  Returns
  -------
  array or list
      For models with a single output this returns a matrix of SHAP values
      (# samples x # features). Each row sums to the difference between the model output for that
      sample and the expected value of the model output (which is stored as expected_value
      attribute of the explainer). For models with vector outputs this returns a list
      of such matrices, one for each output.
docstr_tok: ["Legacy","interface","to","estimate","the","SHAP","values","for","a","set","of","samples",".","Parameters","--","--","--","--","--","X",":","numpy.array","or","pandas.DataFrame","or","any","scipy.sparse","matrix","A","matrix","of","samples","(","#","samples","x","#","features",")","on","which","to","explain","the","model","'s","output",".","npermutations",":","int","Number","of","times","to","cycle","through","all","the","features",",","re-evaluating","the","model","at","each","step",".","Each","cycle","evaluates","the","model","function","2","*","(","#","features","+","1",")","times","on","a","data","matrix","of","(","#","background","data","samples",")","rows",".","An","exception","to","this","is","when","PermutationExplainer","can","avoid","evaluating","the","model","because","a","feature","'s","value","is","the","same","in","X","and","the","background","dataset","(","which","is","common","for","example","with","sparse","features",")",".","Returns","--","--","--","-","array","or","list","For","models","with","a","single","output","this","returns","a","matrix","of","SHAP","values","(","#","samples","x","#","features",")",".","Each","row","sums","to","the","difference","between","the","model","output","for","that","sample","and","the","expected","value","of","the","model","output","(","which","is","stored","as","expected_value","attribute","of","the","explainer",")",".","For","models","with","vector","outputs","this","returns","a","list","of","such","matrices",",","one","for","each","output","."]
code: def shap_values(
      self,
      X,
      npermutations=10,
      main_effects=False,
      error_bounds=False,
      batch_evals=True,
      silent=False,
  ):
      """Legacy interface to estimate the SHAP values for a set of samples.
  
      Parameters
      ----------
      X : numpy.array or pandas.DataFrame or any scipy.sparse matrix
          A matrix of samples (# samples x # features) on which to explain the model's output.
  
      npermutations : int
          Number of times to cycle through all the features, re-evaluating the model at each step.
          Each cycle evaluates the model function 2 * (# features + 1) times on a data matrix of
          (# background data samples) rows. An exception to this is when PermutationExplainer can
          avoid evaluating the model because a feature's value is the same in X and the background
          dataset (which is common for example with sparse features).
  
      Returns
      -------
      array or list
          For models with a single output this returns a matrix of SHAP values
          (# samples x # features). Each row sums to the difference between the model output for that
          sample and the expected value of the model output (which is stored as expected_value
          attribute of the explainer). For models with vector outputs this returns a list
          of such matrices, one for each output.
      """
      warnings.warn(
          "shap_values() is deprecated; use __call__().",
          DeprecationWarning,
      )
  
      explanation = self(
          X,
          max_evals=npermutations * X.shape[1],
          main_effects=main_effects,
      )
      return explanation.values
  
file_path: shap/shap/explainers/_permutation.py
imports: import warnings
  import numpy
  from ..None import links
  from ..models import Model
  from ..utils import MaskedModel, partition_tree_shuffle
  from ._explainer import Explainer
label_desc: Use image node_id 4 for calling the PermutationExplainer obj's underlying member method code with example usage: obj.shap_values(X, npermutations, main_effects, error_bounds, batch_evals, silent) and returns: explanation