class_docstr: A common base class for Independent and Partition.
      
class_docstr_tok: ["A","common","base","class","for","Independent","and","Partition","."]
docstr: This masks out tabular features by integrating over the given background dataset.
  
  Parameters
  ----------
  data : np.array, pandas.DataFrame
      The background dataset that is used for masking.
  
  max_samples : int
      The maximum number of samples to use from the passed background data. If data has more
      than max_samples then shap.utils.sample is used to subsample the dataset. The number of
      samples coming out of the masker (to be integrated over) matches the number of samples in
      the background dataset. This means larger background dataset cause longer runtimes. Normally
      about 1, 10, 100, or 1000 background samples are reasonable choices.
  
  clustering : string or None (default) or numpy.ndarray
      The distance metric to use for creating the clustering of the features. The
      distance function can be any valid scipy.spatial.distance.pdist's metric argument.
      However we suggest using 'correlation' in most cases. The full list of options is
      `braycurtis`, `canberra`, `chebyshev`, `cityblock`, `correlation`, `cosine`, `dice`,
      `euclidean`, `hamming`, `jaccard`, `jensenshannon`, `kulsinski`, `mahalanobis`,
      `matching`, `minkowski`, `rogerstanimoto`, `russellrao`, `seuclidean`,
      `sokalmichener`, `sokalsneath`, `sqeuclidean`, `yule`. These are all
      the options from scipy.spatial.distance.pdist's metric argument.
docstr_tok: ["This","masks","out","tabular","features","by","integrating","over","the","given","background","dataset",".","Parameters","--","--","--","--","--","data",":","np.array",",","pandas.DataFrame","The","background","dataset","that","is","used","for","masking",".","max_samples",":","int","The","maximum","number","of","samples","to","use","from","the","passed","background","data",".","If","data","has","more","than","max_samples","then","shap.utils.sample","is","used","to","subsample","the","dataset",".","The","number","of","samples","coming","out","of","the","masker","(","to","be","integrated","over",")","matches","the","number","of","samples","in","the","background","dataset",".","This","means","larger","background","dataset","cause","longer","runtimes",".","Normally","about","1",",","10",",","100",",","or","1000","background","samples","are","reasonable","choices",".","clustering",":","string","or","None","(","default",")","or","numpy.ndarray","The","distance","metric","to","use","for","creating","the","clustering","of","the","features",".","The","distance","function","can","be","any","valid","scipy.spatial.distance.pdist","'s","metric","argument",".","However","we","suggest","using","'correlation","'","in","most","cases",".","The","full","list","of","options","is","`","braycurtis","`",",","`","canberra","`",",","`","chebyshev","`",",","`","cityblock","`",",","`","correlation","`",",","`","cosine","`",",","`","dice","`",",","`","euclidean","`",",","`","hamming","`",",","`","jaccard","`",",","`","jensenshannon","`",",","`","kulsinski","`",",","`","mahalanobis","`",",","`","matching","`",",","`","minkowski","`",",","`","rogerstanimoto","`",",","`","russellrao","`",",","`","seuclidean","`",",","`","sokalmichener","`",",","`","sokalsneath","`",",","`","sqeuclidean","`",",","`","yule","`",".","These","are","all","the","options","from","scipy.spatial.distance.pdist","'s","metric","argument","."]
code: def __init__(self, data, max_samples=100, clustering=None):
      """This masks out tabular features by integrating over the given background dataset.
  
      Parameters
      ----------
      data : np.array, pandas.DataFrame
          The background dataset that is used for masking.
  
      max_samples : int
          The maximum number of samples to use from the passed background data. If data has more
          than max_samples then shap.utils.sample is used to subsample the dataset. The number of
          samples coming out of the masker (to be integrated over) matches the number of samples in
          the background dataset. This means larger background dataset cause longer runtimes. Normally
          about 1, 10, 100, or 1000 background samples are reasonable choices.
  
      clustering : string or None (default) or numpy.ndarray
          The distance metric to use for creating the clustering of the features. The
          distance function can be any valid scipy.spatial.distance.pdist's metric argument.
          However we suggest using 'correlation' in most cases. The full list of options is
          `braycurtis`, `canberra`, `chebyshev`, `cityblock`, `correlation`, `cosine`, `dice`,
          `euclidean`, `hamming`, `jaccard`, `jensenshannon`, `kulsinski`, `mahalanobis`,
          `matching`, `minkowski`, `rogerstanimoto`, `russellrao`, `seuclidean`,
          `sokalmichener`, `sokalsneath`, `sqeuclidean`, `yule`. These are all
          the options from scipy.spatial.distance.pdist's metric argument.
      """
  
      self.output_dataframe = False
      if isinstance(data, pd.DataFrame):
          self.feature_names = data.columns
          data = data.values
          self.output_dataframe = True
  
      if isinstance(data, dict) and "mean" in data:
          self.mean = data.get("mean", None)
          self.cov = data.get("cov", None)
          data = np.expand_dims(data["mean"], 0)
  
      if hasattr(data, "shape") and data.shape[0] > max_samples:
          data = utils.sample(data, max_samples)
  
      self.data = data
      self.clustering = clustering
      self.max_samples = max_samples
  
      # # warn users about large background data sets
      # if self.data.shape[0] > 100:
      #     log.warning("Using " + str(self.data.shape[0]) + " background data samples could cause slower " +
      #                 "run times. Consider shap.utils.sample(data, K) to summarize the background using only K samples.")
  
      # compute the clustering of the data
      if clustering is not None:
          if isinstance(clustering, str):
              self.clustering = utils.hclust(data, metric=clustering)
          elif isinstance(clustering, np.ndarray):
              self.clustering = clustering
          else:
              raise InvalidClusteringError(
                  "Unknown clustering given! Make sure you pass a distance metric as a string, or a clustering as a numpy.ndarray."
              )
      else:
          self.clustering = None
  
      # self._last_mask = np.zeros(self.data.shape[1], dtype=bool)
      self._masked_data = data.copy()
      self._last_mask = np.zeros(data.shape[1], dtype=bool)
      self.shape = self.data.shape
      self.supports_delta_masking = True
  
imports: import logging
  import numpy
  import pandas
  from numba import njit
  from ..None import utils
  from .._serializable import Deserializer, Serializer
  from ..utils import MaskedModel
  from ..utils._exceptions import DimensionError, InvalidClusteringError
  from ._masker import Masker
label_desc: Use image node_id 1 to create a new Tabular object from inherited base classes: Masker with example: obj = Tabular(data, max_samples, clustering)