class_docstr: Default encoder class with inbuilt function for decoding text that
  has been encoded by the same object. Also supports label encoding.
  Can be used as a skeleton to build more sophisticated encoders on top.
class_docstr_tok: ["Default","encoder","class","with","inbuilt","function","for","decoding","text","that","has","been","encoded","by","the","same","object",".","Also","supports","label","encoding",".","Can","be","used","as","a","skeleton","to","build","more","sophisticated","encoders","on","top","."]
docstr: Encodes the dataset from string form to encoded vector form using
      the tokenizer and vectorizer.
  
  Arguments:
      X_str {[iterable over strings]} -- The X data in string form.
  
  Keyword Arguments:
      needs_fit {bool} -- Whether the vectorizer itself needs to be
          trained or not. (default: {True})
      keep_ids {bool} -- Whether to preserve position of encoded words
          with respect to raw document. Has to be False for training. Has to
          be True for explanations and decoding.(default: {False})
  
  Returns:
      [List with 2 components] --
      * X_vec -- The dataset vectorized and encoded to numeric form.
      * self.vectorizer -- trained vectorizer.
docstr_tok: ["Encodes","the","dataset","from","string","form","to","encoded","vector","form","using","the","tokenizer","and","vectorizer",".","Arguments",":","X_str","{","[","iterable","over","strings","]","}","--","The","X","data","in","string","form",".","Keyword","Arguments",":","needs_fit","{","bool","}","--","Whether","the","vectorizer","itself","needs","to","be","trained","or","not",".","(","default",":","{","True","}",")","keep_ids","{","bool","}","--","Whether","to","preserve","position","of","encoded","words","with","respect","to","raw","document",".","Has","to","be","False","for","training",".","Has","to","be","True","for","explanations","and","decoding",".","(","default",":","{","False","}",")","Returns",":","[","List","with","2","components","]","--","*","X_vec","--","The","dataset","vectorized","and","encoded","to","numeric","form",".","*","self.vectorizer","--","trained","vectorizer","."]
code: def encode_features(self, X_str, needs_fit=True, keep_ids=False):
      """Encodes the dataset from string form to encoded vector form using
          the tokenizer and vectorizer.
  
      Arguments:
          X_str {[iterable over strings]} -- The X data in string form.
  
      Keyword Arguments:
          needs_fit {bool} -- Whether the vectorizer itself needs to be
              trained or not. (default: {True})
          keep_ids {bool} -- Whether to preserve position of encoded words
              with respect to raw document. Has to be False for training. Has to
              be True for explanations and decoding.(default: {False})
  
      Returns:
          [List with 2 components] --
          * X_vec -- The dataset vectorized and encoded to numeric form.
          * self.vectorizer -- trained vectorizer.
      """
      # encoding while preserving ids, used only for importance computation
      # and not during training
      if keep_ids is True and isinstance(X_str, str):
          X_str = self.tokenizer.tokenize(X_str, keep_ids=True)
      # needs_fit will be set to true if encoder is not already trained
      if needs_fit is True:
          self.vectorizer.fit(X_str)
      if isinstance(X_str, str):
          X_str = [X_str]
      X_vec = self.vectorizer.transform(X_str)
      return [X_vec, self.vectorizer]
  
file_path: interpret-text/python/interpret_text/experimental/common/utils_classical.py
imports: import spacy
  import html
  import string
  import numpy
  import matplotlib.pyplot
  from sklearn.preprocessing import LabelEncoder
  from IPython.core.display import display, HTML
  from sklearn.feature_extraction.text import CountVectorizer
label_desc: Use image node_id 2 for calling the BOWEncoder obj's underlying member method code with example usage: obj.encode_features(X_str, needs_fit, keep_ids) and returns: list