class_docstr: Learnable Models
class_docstr_tok: ["Learnable","Models"]
docstr: Learn model from the base model
  
  .. note::
  
      The attribute names of learned model should `not` start with '_'. So that the model could be
      dumped to disk.
  
  The following code example shows how to retrieve `x_train`, `y_train` and `w_train` from the `dataset`:
  
      .. code-block:: Python
  
          # get features and labels
          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"]
  
          # get weights
          try:
              wdf_train, wdf_valid = dataset.prepare(["train", "valid"], col_set=["weight"],
                                                     data_key=DataHandlerLP.DK_L)
              w_train, w_valid = wdf_train["weight"], wdf_valid["weight"]
          except KeyError as e:
              w_train = pd.DataFrame(np.ones_like(y_train.values), index=y_train.index)
              w_valid = pd.DataFrame(np.ones_like(y_valid.values), index=y_valid.index)
  
  Parameters
  ----------
  dataset : Dataset
      dataset will generate the processed data from model training.
docstr_tok: ["Learn","model","from","the","base","model","..","note",":",":","The","attribute","names","of","learned","model","should","`","not","`","start","with","'","_","'",".","So","that","the","model","could","be","dumped","to","disk",".","The","following","code","example","shows","how","to","retrieve","`","x_train","`",",","`","y_train","`","and","`","w_train","`","from","the","`","dataset","`",":","..","code-block",":",":","Python","#","get","features","and","labels","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","''","]","#","get","weights","try",":","wdf_train",",","wdf_valid","=","dataset.prepare","(","[","``","train","''",",","``","valid","''","]",",","col_set=","[","``","weight","''","]",",","data_key=DataHandlerLP.DK_L",")","w_train",",","w_valid","=","wdf_train","[","``","weight","''","]",",","wdf_valid","[","``","weight","''","]","except","KeyError","as","e",":","w_train","=","pd.DataFrame","(","np.ones_like","(","y_train.values",")",",","index=y_train.index",")","w_valid","=","pd.DataFrame","(","np.ones_like","(","y_valid.values",")",",","index=y_valid.index",")","Parameters","--","--","--","--","--","dataset",":","Dataset","dataset","will","generate","the","processed","data","from","model","training","."]
code: def fit(self, dataset: Dataset, reweighter: Reweighter):
      """
      Learn model from the base model
  
      .. note::
  
          The attribute names of learned model should `not` start with '_'. So that the model could be
          dumped to disk.
  
      The following code example shows how to retrieve `x_train`, `y_train` and `w_train` from the `dataset`:
  
          .. code-block:: Python
  
              # get features and labels
              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"]
  
              # get weights
              try:
                  wdf_train, wdf_valid = dataset.prepare(["train", "valid"], col_set=["weight"],
                                                         data_key=DataHandlerLP.DK_L)
                  w_train, w_valid = wdf_train["weight"], wdf_valid["weight"]
              except KeyError as e:
                  w_train = pd.DataFrame(np.ones_like(y_train.values), index=y_train.index)
                  w_valid = pd.DataFrame(np.ones_like(y_valid.values), index=y_valid.index)
  
      Parameters
      ----------
      dataset : Dataset
          dataset will generate the processed data from model training.
  
      """
      raise NotImplementedError()
  
file_path: qlib/qlib/model/base.py
imports: import abc
  from typing import Text, Union
  from ..utils.serial import Serializable
  from ..data.dataset import Dataset
  from ..data.dataset.weight import Reweighter
label_desc: Use image node_id 1 for calling the Model obj's underlying member method code with example usage: obj.fit(dataset, reweighter) without return types