class_docstr: Base class for BoostSearch meta-estimator.
  
  Warning: This class should not be used directly. Use derived classes
  instead.
class_docstr_tok: ["Base","class","for","BoostSearch","meta-estimator",".","Warning",":","This","class","should","not","be","used","directly",".","Use","derived","classes","instead","."]
docstr: Private method to fit a single boosting model and extract results.
docstr_tok: ["Private","method","to","fit","a","single","boosting","model","and","extract","results","."]
code: def _fit(self, X, y, fit_params, params=None):
      """Private method to fit a single boosting model and extract results."""
  
      model = self._build_model(params)
      if isinstance(model, _BoostSelector):
          model.fit(X=X, y=y, **fit_params)
      else:
          with contextlib.redirect_stdout(io.StringIO()):
              model.fit(X=X, y=y, **fit_params)
  
      results = {"params": params, "status": "ok"}
  
      if isinstance(model, _BoostSelector):
          results["booster"] = model.estimator_
          results["model"] = model
      else:
          results["booster"] = model
          results["model"] = None
  
      if "eval_set" not in fit_params:
          return results
  
      if self.boost_type_ == "XGB":
          # w/ eval_set and w/ early_stopping_rounds
          if hasattr(results["booster"], "best_score"):
              results["iterations"] = results["booster"].best_iteration
          # w/ eval_set and w/o early_stopping_rounds
          else:
              valid_id = list(results["booster"].evals_result_.keys())[
                  -1
              ]
              eval_metric = list(
                  results["booster"].evals_result_[valid_id]
              )[-1]
              results["iterations"] = len(
                  results["booster"].evals_result_[valid_id][
                      eval_metric
                  ]
              )
      else:
          # w/ eval_set and w/ early_stopping_rounds
          if results["booster"].best_iteration_ is not None:
              results["iterations"] = results["booster"].best_iteration_
          # w/ eval_set and w/o early_stopping_rounds
          else:
              valid_id = list(results["booster"].evals_result_.keys())[
                  -1
              ]
              eval_metric = list(
                  results["booster"].evals_result_[valid_id]
              )[-1]
              results["iterations"] = len(
                  results["booster"].evals_result_[valid_id][
                      eval_metric
                  ]
              )
  
      if self.boost_type_ == "XGB":
          # w/ eval_set and w/ early_stopping_rounds
          if hasattr(results["booster"], "best_score"):
              results["loss"] = results["booster"].best_score
          # w/ eval_set and w/o early_stopping_rounds
          else:
              valid_id = list(results["booster"].evals_result_.keys())[
                  -1
              ]
              eval_metric = list(
                  results["booster"].evals_result_[valid_id]
              )[-1]
              results["loss"] = results["booster"].evals_result_[
                  valid_id
              ][eval_metric][-1]
      else:
          valid_id = list(results["booster"].best_score_.keys())[-1]
          eval_metric = list(results["booster"].best_score_[valid_id])[
              -1
          ]
          results["loss"] = results["booster"].best_score_[valid_id][
              eval_metric
          ]
  
      if params is not None:
          if self.verbose > 0:
              msg = "trial: {} ### iterations: {} ### eval_score: {}".format(
                  str(self._trial_id).zfill(4),
                  str(results["iterations"]).zfill(5),
                  round(results["loss"], 5),
              )
              print(msg)
  
          self._trial_id += 1
          results["loss"] *= self._score_sign
  
      return results
  
imports: import io
  import contextlib
  import warnings
  import numpy
  import scipy
  from copy import deepcopy
  from sklearn.base import clone
  from sklearn.utils.validation import check_is_fitted
  from sklearn.base import BaseEstimator, TransformerMixin
  from joblib import Parallel, delayed
  from hyperopt import fmin, tpe
  from .utils import ParameterSampler, _check_param, _check_boosting
  from .utils import _set_categorical_indexes, _get_categorical_support
  from .utils import _feature_importances, _shap_importances
label_desc: Use image node_id 3 for calling the _BoostSearch obj's underlying member method code with example usage: obj._fit(X, y, fit_params, params) and returns: results, results