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: Init function.
  
  Args:
      kernel_width: kernel width for the exponential kernel.
      kernel: similarity kernel that takes euclidean distances and kernel
          width as input and outputs weights in (0,1). If None, defaults to
          an exponential kernel.
      verbose: if true, print local prediction values from linear model
      class_names: list of class names, ordered according to whatever the
          classifier is using. If not present, class names will be '0',
          '1', ...
      feature_selection: feature selection method. can be
          'forward_selection', 'lasso_path', 'none' or 'auto'.
          See function 'explain_instance_with_data' in lime_base.py for
          details on what each of the options does.
      split_expression: Regex string or callable. If regex string, will be used with re.split.
          If callable, the function should return a list of tokens.
      bow: if True (bag of words), will perturb input data by removing
          all occurrences of individual words or characters.
          Explanations will be in terms of these words. Otherwise, will
          explain in terms of word-positions, so that a word may be
          important the first time it appears and unimportant the second.
          Only set to false if the classifier uses word order in some way
          (bigrams, etc), or if you set char_level=True.
      mask_string: String used to mask tokens or characters if bow=False
          if None, will be 'UNKWORDZ' if char_level=False, chr(0)
          otherwise.
      random_state: an integer or numpy.RandomState that will be used to
          generate random numbers. If None, the random state will be
          initialized using the internal numpy seed.
      char_level: an boolean identifying that we treat each character
          as an independent occurence in the string
code: def __init__(
      self,
      kernel_width=25,
      kernel=None,
      verbose=False,
      class_names=None,
      feature_selection="auto",
      split_expression=r"\W+",
      bow=True,
      mask_string=None,
      random_state=None,
      char_level=False,
  ):
      """Init function.
  
      Args:
          kernel_width: kernel width for the exponential kernel.
          kernel: similarity kernel that takes euclidean distances and kernel
              width as input and outputs weights in (0,1). If None, defaults to
              an exponential kernel.
          verbose: if true, print local prediction values from linear model
          class_names: list of class names, ordered according to whatever the
              classifier is using. If not present, class names will be '0',
              '1', ...
          feature_selection: feature selection method. can be
              'forward_selection', 'lasso_path', 'none' or 'auto'.
              See function 'explain_instance_with_data' in lime_base.py for
              details on what each of the options does.
          split_expression: Regex string or callable. If regex string, will be used with re.split.
              If callable, the function should return a list of tokens.
          bow: if True (bag of words), will perturb input data by removing
              all occurrences of individual words or characters.
              Explanations will be in terms of these words. Otherwise, will
              explain in terms of word-positions, so that a word may be
              important the first time it appears and unimportant the second.
              Only set to false if the classifier uses word order in some way
              (bigrams, etc), or if you set char_level=True.
          mask_string: String used to mask tokens or characters if bow=False
              if None, will be 'UNKWORDZ' if char_level=False, chr(0)
              otherwise.
          random_state: an integer or numpy.RandomState that will be used to
              generate random numbers. If None, the random state will be
              initialized using the internal numpy seed.
          char_level: an boolean identifying that we treat each character
              as an independent occurence in the string
      """
  
      if kernel is None:
  
          def kernel(d, kernel_width):
              return np.sqrt(np.exp(-(d**2) / kernel_width**2))
  
      kernel_fn = partial(kernel, kernel_width=kernel_width)
  
      self.random_state = check_random_state(random_state)
      self.base = lime_base.LimeBase(
          kernel_fn, verbose, random_state=self.random_state
      )
      self.class_names = class_names
      self.vocabulary = None
      self.feature_selection = feature_selection
      self.bow = bow
      self.mask_string = mask_string
      self.split_expression = split_expression
      self.char_level = char_level
  
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 1 to create a new LimeTextExplainer object from inherited base classes: object with example: obj = LimeTextExplainer(kernel_width, kernel, verbose, class_names, feature_selection, split_expression, bow, mask_string, random_state, char_level)