class_docstr: LightGBM Model for high frequency prediction
class_docstr_tok: ["LightGBM","Model","for","high","frequency","prediction"]
docstr: Calcaute the signal metrics by daily level
docstr_tok: ["Calcaute","the","signal","metrics","by","daily","level"]
code: def _cal_signal_metrics(self, y_test, l_cut, r_cut):
      """
      Calcaute the signal metrics by daily level
      """
      up_pre, down_pre = [], []
      up_alpha_ll, down_alpha_ll = [], []
      for date in y_test.index.get_level_values(0).unique():
          df_res = y_test.loc[date].sort_values("pred")
          if int(l_cut * len(df_res)) < 10:
              warnings.warn(
                  "Warning: threhold is too low or instruments number is not enough"
              )
              continue
          top = df_res.iloc[: int(l_cut * len(df_res))]
          bottom = df_res.iloc[int(r_cut * len(df_res)) :]
  
          down_precision = len(top[top[top.columns[0]] < 0]) / (
              len(top)
          )
          up_precision = len(bottom[bottom[top.columns[0]] > 0]) / (
              len(bottom)
          )
  
          down_alpha = top[top.columns[0]].mean()
          up_alpha = bottom[bottom.columns[0]].mean()
  
          up_pre.append(up_precision)
          down_pre.append(down_precision)
          up_alpha_ll.append(up_alpha)
          down_alpha_ll.append(down_alpha)
  
      return (
          np.array(up_pre).mean(),
          np.array(down_pre).mean(),
          np.array(up_alpha_ll).mean(),
          np.array(down_alpha_ll).mean(),
      )
  
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 2 for calling the HFLGBModel obj's underlying member method code with example usage: obj._cal_signal_metrics(y_test, l_cut, r_cut) and returns: np,  np,  np,  np