class_docstr: Linear Model
  
  Solve one of the following regression problems:
      - `ols`: min_w |y - Xw|^2_2
      - `nnls`: min_w |y - Xw|^2_2, s.t. w >= 0
      - `ridge`: min_w |y - Xw|^2_2 + lpha*|w|^2_2
      - `lasso`: min_w |y - Xw|^2_2 + lpha*|w|_1
  where `w` is the regression coefficient.
class_docstr_tok: ["Linear","Model","Solve","one","of","the","following","regression","problems",":","-","`","ols","`",":","min_w","|y","-","Xw|^2_2","-","`","nnls","`",":","min_w","|y","-","Xw|^2_2",",","s.t",".","w",">","=","0","-","`","ridge","`",":","min_w","|y","-","Xw|^2_2","+","\u0007lpha","*","|w|^2_2","-","`","lasso","`",":","min_w","|y","-","Xw|^2_2","+","\u0007lpha","*","|w|_1","where","`","w","`","is","the","regression","coefficient","."]
code: def predict(
      self, dataset: DatasetH, segment: Union[Text, slice] = "test"
  ):
      if self.coef_ is None:
          raise ValueError("model is not fitted yet!")
      x_test = dataset.prepare(
          segment, col_set="feature", data_key=DataHandlerLP.DK_I
      )
      return pd.Series(
          x_test.values @ self.coef_ + self.intercept_,
          index=x_test.index,
      )
  
file_path: qlib/qlib/contrib/model/linear.py
imports: import numpy
  import pandas
  from typing import Text, Union
  from qlib.log import get_module_logger
  from qlib.data.dataset.weight import Reweighter
  from scipy.optimize import nnls
  from sklearn.linear_model import LinearRegression, Ridge, Lasso
  from ...model.base import Model
  from ...data.dataset import DatasetH
  from ...data.dataset.handler import DataHandlerLP
label_desc: Use image node_id 5 for calling the LinearModel obj's underlying member method code with example usage: obj.predict(dataset, segment) and returns: pd