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","."]
docstr: Parameters
  ----------
  estimator : str
      which estimator to use for linear regression
  alpha : float
      l1 or l2 regularization parameter
  fit_intercept : bool
      whether fit intercept
  include_valid: bool
      Should the validation data be included for training?
      The validation data should be included
docstr_tok: ["Parameters","--","--","--","--","--","estimator",":","str","which","estimator","to","use","for","linear","regression","alpha",":","float","l1","or","l2","regularization","parameter","fit_intercept",":","bool","whether","fit","intercept","include_valid",":","bool","Should","the","validation","data","be","included","for","training","?","The","validation","data","should","be","included"]
code: def __init__(
      self,
      estimator="ols",
      alpha=0.0,
      fit_intercept=False,
      include_valid: bool = False,
  ):
      """
      Parameters
      ----------
      estimator : str
          which estimator to use for linear regression
      alpha : float
          l1 or l2 regularization parameter
      fit_intercept : bool
          whether fit intercept
      include_valid: bool
          Should the validation data be included for training?
          The validation data should be included
      """
      assert estimator in [
          self.OLS,
          self.NNLS,
          self.RIDGE,
          self.LASSO,
      ], f"unsupported estimator `{estimator}`"
      self.estimator = estimator
  
      assert alpha == 0 or estimator in [
          self.RIDGE,
          self.LASSO,
      ], f"alpha is only supported in `ridge`&`lasso`"
      self.alpha = alpha
  
      self.fit_intercept = fit_intercept
  
      self.coef_ = None
      self.include_valid = include_valid
  
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 1 to create a new LinearModel object from inherited base classes: Model with example: obj = LinearModel(estimator, alpha, fit_intercept, include_valid)