class_docstr: Explains text classifiers.
  Currently, we are using an exponential kernel on cosine distance, and
  restricting explanations to words that are present in documents.
docstr: Generates a neighborhood around a prediction.
  
  Generates neighborhood data by randomly removing words from
  the instance, and predicting with the classifier. Uses cosine distance
  to compute distances between original and perturbed instances.
  Args:
      indexed_string: document (IndexedString) to be explained,
      classifier_fn: classifier prediction probability function, which
          takes a string and outputs prediction probabilities. For
          ScikitClassifier, this is classifier.predict_proba.
      num_samples: size of the neighborhood to learn the linear model
      distance_metric: the distance metric to use for sample weighting,
          defaults to cosine similarity.
  
  
  Returns:
      A tuple (data, labels, distances), where:
          data: dense num_samples * K binary matrix, where K is the
              number of tokens in indexed_string. The first row is the
              original instance, and thus a row of ones.
          labels: num_samples * L matrix, where L is the number of target
              labels
          distances: cosine distance between the original instance and
              each perturbed instance (computed in the binary 'data'
              matrix), times 100.
code: def __data_labels_distances(
      self,
      indexed_string,
      classifier_fn,
      num_samples,
      distance_metric="cosine",
  ):
      """Generates a neighborhood around a prediction.
  
      Generates neighborhood data by randomly removing words from
      the instance, and predicting with the classifier. Uses cosine distance
      to compute distances between original and perturbed instances.
      Args:
          indexed_string: document (IndexedString) to be explained,
          classifier_fn: classifier prediction probability function, which
              takes a string and outputs prediction probabilities. For
              ScikitClassifier, this is classifier.predict_proba.
          num_samples: size of the neighborhood to learn the linear model
          distance_metric: the distance metric to use for sample weighting,
              defaults to cosine similarity.
  
  
      Returns:
          A tuple (data, labels, distances), where:
              data: dense num_samples * K binary matrix, where K is the
                  number of tokens in indexed_string. The first row is the
                  original instance, and thus a row of ones.
              labels: num_samples * L matrix, where L is the number of target
                  labels
              distances: cosine distance between the original instance and
                  each perturbed instance (computed in the binary 'data'
                  matrix), times 100.
      """
  
      def distance_fn(x):
          return (
              sklearn.metrics.pairwise.pairwise_distances(
                  x, x[0], metric=distance_metric
              ).ravel()
              * 100
          )
  
      doc_size = indexed_string.num_words()
      sample = self.random_state.randint(
          1, doc_size + 1, num_samples - 1
      )
      data = np.ones((num_samples, doc_size))
      data[0] = np.ones(doc_size)
      features_range = range(doc_size)
      inverse_data = [indexed_string.raw_string()]
      for i, size in enumerate(sample, start=1):
          inactive = self.random_state.choice(
              features_range, size, replace=False
          )
          data[i, inactive] = 0
          inverse_data.append(indexed_string.inverse_removing(inactive))
      labels = classifier_fn(inverse_data)
      distances = distance_fn(sp.sparse.csr_matrix(data))
      return data, labels, distances
  
imports: from functools import partial
  import itertools
  import json
  import re
  import numpy
  import scipy
  import sklearn
  from sklearn.utils import check_random_state
  from .None import explanation
  from .None import lime_base
label_desc: Use image node_id 3 for calling the LimeTextExplainer obj's underlying member method code with example usage: obj.__data_labels_distances(indexed_string, classifier_fn, num_samples, distance_metric) and returns: data,  labels,  distances, unknown