code: def test_text_explainer_custom_classifier():
      text = "foo-bar baz egg-spam"
      predict_proba = substring_presence_predict_proba("bar")
  
      # use decision tree to explain the prediction
      te = TextExplainer(clf=DecisionTreeClassifier(max_depth=2))
      te.fit(text, predict_proba)
      print(te.metrics_)
      assert te.metrics_["score"] > 0.99
      assert te.metrics_["mean_KL_divergence"] < 0.01
      expl = te.explain_prediction()
      format_as_all(expl, te.clf_)
  
      # with explain_weights we can get a nice tree representation
      expl = te.explain_weights()
      print(expl.decision_tree.tree)
      assert expl.decision_tree.tree.feature_name == "bar"
      format_as_all(expl, te.clf_)
  
file_path: eli5/tests/test_lime.py
imports: from __future__ import absolute_import
  import numpy
  from sklearn.feature_extraction.text import HashingVectorizer, CountVectorizer
  from sklearn.naive_bayes import MultinomialNB
  from sklearn.tree import DecisionTreeClassifier
  from sklearn.pipeline import make_pipeline
  import pytest
  from eli5.lime import TextExplainer
  from eli5.formatters import format_as_text
  from .utils import format_as_all, check_targets_scores
label_desc: Use image node_id 5 for calling a global function with example usage: test_text_explainer_custom_classifier() without return types