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 _fit(self, X, y, w):
      if self.estimator == self.OLS:
          model = LinearRegression(
              fit_intercept=self.fit_intercept, copy_X=False
          )
      else:
          model = {self.RIDGE: Ridge, self.LASSO: Lasso}[
              self.estimator
          ](
              alpha=self.alpha,
              fit_intercept=self.fit_intercept,
              copy_X=False,
          )
      model.fit(X, y, sample_weight=w)
      self.coef_ = model.coef_
      self.intercept_ = model.intercept_
  
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 3 for calling the LinearModel obj's underlying member method code with example usage: obj._fit(X, y, w) without return types