class_docstr: XGBModel Model
class_docstr_tok: ["XGBModel","Model"]
code: def fit(
      self,
      dataset: DatasetH,
      num_boost_round=1000,
      early_stopping_rounds=50,
      verbose_eval=20,
      evals_result=dict(),
      reweighter=None,
      **kwargs,
  ):
      df_train, df_valid = dataset.prepare(
          ["train", "valid"],
          col_set=["feature", "label"],
          data_key=DataHandlerLP.DK_L,
      )
      x_train, y_train = df_train["feature"], df_train["label"]
      x_valid, y_valid = df_valid["feature"], df_valid["label"]
  
      # Lightgbm need 1D array as its label
      if y_train.values.ndim == 2 and y_train.values.shape[1] == 1:
          y_train_1d, y_valid_1d = np.squeeze(
              y_train.values
          ), np.squeeze(y_valid.values)
      else:
          raise ValueError(
              "XGBoost doesn't support multi-label training"
          )
  
      if reweighter is None:
          w_train = None
          w_valid = None
      elif isinstance(reweighter, Reweighter):
          w_train = reweighter.reweight(df_train)
          w_valid = reweighter.reweight(df_valid)
      else:
          raise ValueError("Unsupported reweighter type.")
  
      dtrain = xgb.DMatrix(
          x_train.values, label=y_train_1d, weight=w_train
      )
      dvalid = xgb.DMatrix(
          x_valid.values, label=y_valid_1d, weight=w_valid
      )
      self.model = xgb.train(
          self._params,
          dtrain=dtrain,
          num_boost_round=num_boost_round,
          evals=[(dtrain, "train"), (dvalid, "valid")],
          early_stopping_rounds=early_stopping_rounds,
          verbose_eval=verbose_eval,
          evals_result=evals_result,
          **kwargs,
      )
      evals_result["train"] = list(evals_result["train"].values())[0]
      evals_result["valid"] = list(evals_result["valid"].values())[0]
  
file_path: qlib/qlib/contrib/model/xgboost.py
imports: import numpy
  import pandas
  import xgboost
  from typing import Text, Union
  from ...model.base import Model
  from ...data.dataset import DatasetH
  from ...data.dataset.handler import DataHandlerLP
  from ...model.interpret.base import FeatureInt
  from ...data.dataset.weight import Reweighter
label_desc: Use image node_id 2 for calling the XGBModel obj's underlying member method code with example usage: obj.fit(dataset, num_boost_round, early_stopping_rounds, verbose_eval, evals_result, reweighter) without return types