class_docstr: Explains predictions on Image (i.e. matrix) data.
  For numerical features, perturb them by sampling from a Normal(0,1) and
  doing the inverse operation of mean-centering and scaling, according to the
  means and stds in the training data. For categorical features, perturb by
  sampling according to the training distribution, and making a binary
  feature that is 1 when the value is the same as the instance being
  explained.
class_docstr_tok: ["Explains","predictions","on","Image","(","i.e",".","matrix",")","data",".","For","numerical","features",",","perturb","them","by","sampling","from","a","Normal","(","0,1",")","and","doing","the","inverse","operation","of","mean-centering","and","scaling",",","according","to","the","means","and","stds","in","the","training","data",".","For","categorical","features",",","perturb","by","sampling","according","to","the","training","distribution",",","and","making","a","binary","feature","that","is","1","when","the","value","is","the","same","as","the","instance","being","explained","."]
docstr: Generates images and predictions in the neighborhood of this image.
  
  Args:
      image: 3d numpy array, the image
      fudged_image: 3d numpy array, image to replace original image when
          superpixel is turned off
      segments: segmentation of the image
      classifier_fn: function that takes a list of images and returns a
          matrix of prediction probabilities
      num_samples: size of the neighborhood to learn the linear model
      batch_size: classifier_fn will be called on batches of this size.
      progress_bar: if True, show tqdm progress bar.
  
  Returns:
      A tuple (data, labels), where:
          data: dense num_samples * num_superpixels
          labels: prediction probabilities matrix
docstr_tok: ["Generates","images","and","predictions","in","the","neighborhood","of","this","image",".","Args",":","image",":","3d","numpy","array",",","the","image","fudged_image",":","3d","numpy","array",",","image","to","replace","original","image","when","superpixel","is","turned","off","segments",":","segmentation","of","the","image","classifier_fn",":","function","that","takes","a","list","of","images","and","returns","a","matrix","of","prediction","probabilities","num_samples",":","size","of","the","neighborhood","to","learn","the","linear","model","batch_size",":","classifier_fn","will","be","called","on","batches","of","this","size",".","progress_bar",":","if","True",",","show","tqdm","progress","bar",".","Returns",":","A","tuple","(","data",",","labels",")",",","where",":","data",":","dense","num_samples","*","num_superpixels","labels",":","prediction","probabilities","matrix"]
code: def data_labels(
      self,
      image,
      fudged_image,
      segments,
      classifier_fn,
      num_samples,
      batch_size=10,
      progress_bar=True,
  ):
      """Generates images and predictions in the neighborhood of this image.
  
      Args:
          image: 3d numpy array, the image
          fudged_image: 3d numpy array, image to replace original image when
              superpixel is turned off
          segments: segmentation of the image
          classifier_fn: function that takes a list of images and returns a
              matrix of prediction probabilities
          num_samples: size of the neighborhood to learn the linear model
          batch_size: classifier_fn will be called on batches of this size.
          progress_bar: if True, show tqdm progress bar.
  
      Returns:
          A tuple (data, labels), where:
              data: dense num_samples * num_superpixels
              labels: prediction probabilities matrix
      """
      n_features = np.unique(segments).shape[0]
      data = self.random_state.randint(
          0, 2, num_samples * n_features
      ).reshape((num_samples, n_features))
      labels = []
      data[0, :] = 1
      imgs = []
      rows = tqdm(data) if progress_bar else data
      for row in rows:
          temp = copy.deepcopy(image)
          zeros = np.where(row == 0)[0]
          mask = np.zeros(segments.shape).astype(bool)
          for z in zeros:
              mask[segments == z] = True
          temp[mask] = fudged_image[mask]
          imgs.append(temp)
          if len(imgs) == batch_size:
              preds = classifier_fn(np.array(imgs))
              labels.extend(preds)
              imgs = []
      if len(imgs) > 0:
          preds = classifier_fn(np.array(imgs))
          labels.extend(preds)
      return data, np.array(labels)
  
file_path: lime/lime/lime_image.py
imports: import copy
  from functools import partial
  import numpy
  import sklearn
  from sklearn.utils import check_random_state
  from skimage.color import gray2rgb
  from tqdm.auto import tqdm
  from .None import lime_base
  from .wrappers.scikit_image import SegmentationAlgorithm
label_desc: Use image node_id 3 for calling the LimeImageExplainer obj's underlying member method code with example usage: obj.data_labels(image, fudged_image, segments, classifier_fn, num_samples, batch_size, progress_bar) and returns: data,  np