code: def test_explain_prediction_clf_binary(
      newsgroups_train_binary_big, missing, use_booster
  ):
      docs, ys, target_names = newsgroups_train_binary_big
      vec = CountVectorizer(stop_words="english")
      xs = vec.fit_transform(docs)
      explain_kwargs = {}
      if use_booster:
          clf = xgboost.train(
              params={
                  "objective": "binary:logistic",
                  "silent": True,
                  "max_depth": 2,
              },
              dtrain=xgboost.DMatrix(xs, label=ys, missing=missing),
              num_boost_round=100,
          )
          explain_kwargs.update(
              {"missing": missing, "is_regression": False}
          )
      else:
          clf = XGBClassifier(
              n_estimators=100, max_depth=2, missing=missing
          )
          clf.fit(xs, ys)
      get_res = lambda **kwargs: explain_prediction(
          clf,
          "computer graphics in space: a sign of atheism",
          vec=vec,
          target_names=target_names,
          **dict(kwargs, **explain_kwargs),
      )
      res = get_res()
      for expl in format_as_all(res, clf, show_feature_values=True):
          assert "graphics" in expl
          assert "Missing" in expl
      check_targets_scores(res)
      weights = res.targets[0].feature_weights
      pos_features = get_all_features(weights.pos)
      neg_features = get_all_features(weights.neg)
      assert "graphics" in pos_features
      assert "computer" in pos_features
      assert "atheism" in neg_features
  
      flt_res = get_res(feature_re="gra")
      flt_pos_features = get_all_features(
          flt_res.targets[0].feature_weights.pos
      )
      assert "graphics" in flt_pos_features
      assert "computer" not in flt_pos_features
  
      flt_value_res = get_res(
          feature_filter=lambda _, v: not np.isnan(v)
      )
      for expl in format_as_all(
          flt_value_res, clf, show_feature_values=True
      ):
          assert "Missing" not in expl
  
imports: from __future__ import absolute_import
  import pytest
  import numpy
  import scipy.sparse
  from sklearn.feature_extraction.text import CountVectorizer
  import xgboost
  from xgboost import XGBClassifier, XGBRegressor
  from sklearn.pipeline import FeatureUnion
  from sklearn.preprocessing import FunctionTransformer
  from eli5.xgboost import _parse_tree_dump, _xgb_n_targets, _missing_values_set_to_nan, _parent_value, _parse_dump_line, _check_booster_args
  from eli5.explain import explain_prediction, explain_weights
  from eli5.formatters.text import format_as_text
  from eli5.formatters import fields
  from .utils import format_as_all, get_all_features, check_targets_scores
  from .test_sklearn_explain_weights import test_explain_tree_classifier, test_explain_random_forest_and_tree_feature_filter, test_feature_importances_no_remaining, assert_tree_classifier_explained
  from .test_sklearn_explain_prediction import assert_linear_regression_explained, assert_trained_linear_regression_explained, assert_explain_prediction_single_target, test_explain_clf_binary_iris, test_explain_prediction_pandas
label_desc: Use image node_id 7 for calling a global function with example usage: test_explain_prediction_clf_binary(newsgroups_train_binary_big, missing, use_booster) without return types