code: def test_lime_explain_probabilistic(newsgroups_train):
      docs, y, target_names = newsgroups_train
      try:
          vec = HashingVectorizer(alternate_sign=False)
      except TypeError:
          # sklearn < 0.19
          vec = HashingVectorizer(non_negative=True)
      clf = MultinomialNB()
  
      X = vec.fit_transform(docs)
      clf.fit(X, y)
      print(clf.score(X, y))
  
      pipe = make_pipeline(vec, clf)
      doc = docs[0]
  
      te = TextExplainer(random_state=42)
      te.fit(doc, pipe.predict_proba)
  
      print(te.metrics_)
      assert te.metrics_["score"] > 0.7
      assert te.metrics_["mean_KL_divergence"] < 0.1
  
      res = te.explain_prediction(top=20, target_names=target_names)
      expl = format_as_text(res)
      print(expl)
      assert "file" in expl
  
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 1 for calling a global function with example usage: test_lime_explain_probabilistic(newsgroups_train) without return types