class_docstr: LightGBM Model for high frequency prediction
class_docstr_tok: ["LightGBM","Model","for","high","frequency","prediction"]
code: def _prepare_data(self, dataset: DatasetH):
      df_train, df_valid = dataset.prepare(
          ["train", "valid"],
          col_set=["feature", "label"],
          data_key=DataHandlerLP.DK_L,
      )
      if df_train.empty or df_valid.empty:
          raise ValueError(
              "Empty data from dataset, please check your dataset config."
          )
  
      x_train, y_train = df_train["feature"], df_train["label"]
      x_valid, y_valid = df_valid["feature"], df_valid["label"]
      if y_train.values.ndim == 2 and y_train.values.shape[1] == 1:
          l_name = df_train["label"].columns[0]
          # Convert label into alpha
          df_train["label"][l_name] = df_train["label"][
              l_name
          ] - df_train["label"][l_name].mean(level=0)
          df_valid["label"][l_name] = df_valid["label"][
              l_name
          ] - df_valid["label"][l_name].mean(level=0)
  
          def mapping_fn(x):
              return 0 if x < 0 else 1
  
          df_train["label_c"] = df_train["label"][l_name].apply(
              mapping_fn
          )
          df_valid["label_c"] = df_valid["label"][l_name].apply(
              mapping_fn
          )
          x_train, y_train = (
              df_train["feature"],
              df_train["label_c"].values,
          )
          x_valid, y_valid = (
              df_valid["feature"],
              df_valid["label_c"].values,
          )
      else:
          raise ValueError(
              "LightGBM doesn't support multi-label training"
          )
  
      dtrain = lgb.Dataset(x_train, label=y_train)
      dvalid = lgb.Dataset(x_valid, label=y_valid)
      return dtrain, dvalid
  
file_path: qlib/qlib/contrib/model/highfreq_gdbt_model.py
imports: import warnings
  import numpy
  import pandas
  import lightgbm
  from ...model.base import ModelFT
  from ...data.dataset import DatasetH
  from ...data.dataset.handler import DataHandlerLP
  from ...model.interpret.base import LightGBMFInt
label_desc: Use image node_id 4 for calling the HFLGBModel obj's underlying member method code with example usage: obj._prepare_data(dataset) and returns: dtrain,  dvalid, unknown