class_docstr: The ClassicalTextExplainer for returning explanations for n-gram
  bag-of-words models using sklearn's classifier API.
  Also serves as extensible wrapper with components built to support addition
  of fresh explainers using certain parts of this class.
class_docstr_tok: ["The","ClassicalTextExplainer","for","returning","explanations","for","n-gram","bag-of-words","models","using","sklearn","'s","classifier","API",".","Also","serves","as","extensible","wrapper","with","components","built","to","support","addition","of","fresh","explainers","using","certain","parts","of","this","class","."]
docstr: Returns an explanation object containing explanations over words
      in the input text string.
  :param X: String to be explained.
  :type X: str
  :param y: The predicted label for the sentence
  :type y: string
  :param name: a name for saving the explanation, currently ignored
  :type str
  :return: A model explanation object containing importances and metadata.
  :rtype: LocalExplanation
docstr_tok: ["Returns","an","explanation","object","containing","explanations","over","words","in","the","input","text","string",".",":","param","X",":","String","to","be","explained",".",":","type","X",":","str",":","param","y",":","The","predicted","label","for","the","sentence",":","type","y",":","string",":","param","name",":","a","name","for","saving","the","explanation",",","currently","ignored",":","type","str",":","return",":","A","model","explanation","object","containing","importances","and","metadata",".",":","rtype",":","LocalExplanation"]
code: def explain_local(self, X, y=None, name=None):
      """Returns an explanation object containing explanations over words
          in the input text string.
      :param X: String to be explained.
      :type X: str
      :param y: The predicted label for the sentence
      :type y: string
      :param name: a name for saving the explanation, currently ignored
      :type str
      :return: A model explanation object containing importances and metadata.
      :rtype: LocalExplanation
      """
      X = _validate_X(X)
  
      [encoded_text, _] = self.preprocessor.encode_features(
          X, needs_fit=False
      )
      encoded_label = self.model.predict(encoded_text)
  
      if y is None:
          y = self.preprocessor.labelEncoder.inverse_transform(
              encoded_label
          )
  
      # convert from vector to scalar
      encoded_label = encoded_label[0]
  
      # Obtain the top feature ids for the selected class label
      if hasattr(self.model, "coef_"):
          # when #labels == 2, coef_ returns 1D array
          label_coefs_all = self.model.coef_
          if len(self.preprocessor.labelEncoder.classes_) == 2:
              label_coefs_all = np.vstack(
                  (-1 * label_coefs_all, label_coefs_all)
              )
          encoded_imp = label_coefs_all[encoded_label, :]
      elif hasattr(self.model, "feature_importances_"):
          encoded_imp = self.model.feature_importances_
      else:
          raise Exception(
              "model is missing coef_ or feature_importances_ attribute"
          )
      decoded_imp, parsed_sentence_list = self.preprocessor.decode_imp(
          encoded_imp, X
      )
  
      local_explanantion = _create_local_explanation(
          classification=True,
          text_explanation=True,
          local_importance_values=np.array(decoded_imp),
          method=str(type(self.model)),
          model_task="classification",
          features=parsed_sentence_list,
          classes=self.preprocessor.labelEncoder.classes_,
          predicted_label=y,
      )
      return local_explanantion
  
file_path: interpret-text/python/interpret_text/experimental/classical.py
imports: import numpy
  from sklearn.model_selection import GridSearchCV
  from sklearn.linear_model import LogisticRegression
  from sklearn.pipeline import Pipeline
  from interpret_text.experimental.common.base_explainer import _validate_X
  from interpret_text.experimental.common.utils_classical import BOWEncoder
  from interpret_text.experimental.common.constants import ExplainerParams
  from interpret_text.experimental.explanation import _create_local_explanation
label_desc: Use image node_id 5 for calling the ClassicalTextExplainer obj's underlying member method code with example usage: obj.explain_local(X, y, name) and returns: local_explanantion