class_docstr: Unit test class for testing xgboost converter and running both models
class_docstr_tok: ["Unit","test","class","for","testing","xgboost","converter","and","running","both","models"]
docstr: Train a scikit-learn model, convert it and then evaluate it with CoreML
docstr_tok: ["Train","a","scikit-learn","model",",","convert","it","and","then","evaluate","it","with","CoreML"]
code: def _train_convert_evaluate_assert(self, **xgboost_params):
      """
      Train a scikit-learn model, convert it and then evaluate it with CoreML
      """
      xgb_model = xgboost.XGBClassifier(**xgboost_params)
      xgb_model.fit(self.X, self.target)
  
      # Convert the model
      spec = xgb_converter.convert(
          xgb_model,
          self.feature_names,
          self.output_name,
          mode="classifier",
      )
  
      if _is_macos() and _macos_version() >= (10, 13):
          # Get predictions
          df = pd.DataFrame(self.X, columns=self.feature_names)
          probabilities = xgb_model.predict_proba(self.X)
          df["classProbability"] = [
              dict(zip(xgb_model.classes_, cur_vals))
              for cur_vals in probabilities
          ]
          metrics = evaluate_classifier_with_probabilities(
              spec, df, probabilities="classProbability", verbose=False
          )
          self.assertEqual(metrics["num_key_mismatch"], 0)
          self.assertLess(metrics["max_probability_error"], 1e-3)
  
imports: import itertools
  import unittest
  import numpy
  import pandas
  import pytest
  from coremltools._deps import _HAS_SKLEARN, _HAS_XGBOOST
  from coremltools.models.utils import _is_macos, _macos_version, evaluate_classifier, evaluate_classifier_with_probabilities
label_desc: Use image node_id 2 for calling the BoostedTreeClassificationBostonHousingXGboostNumericTest obj's underlying member method code with example usage: obj._train_convert_evaluate_assert() without return types