code: def test_binary_classification():
      from sklearn.datasets import load_digits
      from sklearn.model_selection import KFold
  
      digits = load_digits(n_class=2)
      y = digits["target"]
      X = digits["data"]
      kf = KFold(n_splits=2, shuffle=True, random_state=rng)
      for cls in (xgb.XGBClassifier, xgb.XGBRFClassifier):
          for train_index, test_index in kf.split(X, y):
              clf = cls(random_state=42, eval_metric=["auc", "logloss"])
              xgb_model = clf.fit(X[train_index], y[train_index])
              preds = xgb_model.predict(X[test_index])
              labels = y[test_index]
              err = sum(
                  1
                  for i in range(len(preds))
                  if int(preds[i] > 0.5) != labels[i]
              ) / float(len(preds))
              assert err < 0.1
  
imports: import json
  import os
  import pickle
  import random
  import tempfile
  import warnings
  from typing import Callable, Optional
  import numpy
  import pytest
  from sklearn.utils.estimator_checks import parametrize_with_checks
  import xgboost
  from xgboost import testing
  from xgboost.testing.ranking import run_ranking_categorical, run_ranking_qid_df
  from xgboost.testing.shared import get_feature_weights, validate_data_initialization
  from xgboost.testing.updater import get_basescore
label_desc: Use image node_id 1 for calling a global function with example usage: test_binary_classification() without return types