class_docstr: Generalized Linear Model.
  
  This serves as a base class for linear and logistic regression.
  
  Parameters
  ----------
  optimizer
      The sequential optimizer used for updating the weights. Note that the intercept updates are
      handled separately.
  loss
      The loss function to optimize for.
  l2
      Amount of L2 regularization used to push weights towards 0.
      For now, only one type of penalty can be used. The joint use of L1 and L2 is not explicitly supported.
  l1
      Amount of L1 regularization used to push weights towards 0.
      For now, only one type of penalty can be used. The joint use of L1 and L2 is not explicitly supported.
  intercept_init
      Initial intercept value.
  intercept_lr
      Learning rate scheduler used for updating the intercept. A `optim.schedulers.Constant` is
      used if a `float` is provided. The intercept is not updated when this is set to 0.
  clip_gradient
      Clips the absolute value of each gradient value.
  initializer
      Weights initialization scheme.
class_docstr_tok: ["Generalized","Linear","Model",".","This","serves","as","a","base","class","for","linear","and","logistic","regression",".","Parameters","--","--","--","--","--","optimizer","The","sequential","optimizer","used","for","updating","the","weights",".","Note","that","the","intercept","updates","are","handled","separately",".","loss","The","loss","function","to","optimize","for",".","l2","Amount","of","L2","regularization","used","to","push","weights","towards","0",".","For","now",",","only","one","type","of","penalty","can","be","used",".","The","joint","use","of","L1","and","L2","is","not","explicitly","supported",".","l1","Amount","of","L1","regularization","used","to","push","weights","towards","0",".","For","now",",","only","one","type","of","penalty","can","be","used",".","The","joint","use","of","L1","and","L2","is","not","explicitly","supported",".","intercept_init","Initial","intercept","value",".","intercept_lr","Learning","rate","scheduler","used","for","updating","the","intercept",".","A","`","optim.schedulers.Constant","`","is","used","if","a","`","float","`","is","provided",".","The","intercept","is","not","updated","when","this","is","set","to","0.","clip_gradient","Clips","the","absolute","value","of","each","gradient","value",".","initializer","Weights","initialization","scheme","."]
code: def _fit(self, x, y, w, get_grad):
      # Some optimizers need to do something before a prediction is made
      self.optimizer.look_ahead(w=self._weights)
  
      # Calculate the gradient
      gradient, loss_gradient = get_grad(x, y, w)
  
      # Update the intercept
      self.intercept -= self._get_intercept_update(loss_gradient)
  
      # Update the weights
      self.optimizer.step(w=self._weights, g=gradient)
  
      # Apply L1 cumulative penalty if applicable
      if self.l1 != 0.0:
          # This should be called after the learning_rate update in case of adaptive learning rate
          self.max_cum_l1 = (
              self.max_cum_l1 + self.l1 * self.optimizer.learning_rate
          )
  
          self._update_weights(x)
  
      return self
  
file_path: river/river/linear_model/base.py
imports: from __future__ import annotations
  import contextlib
  import numbers
  import numpy
  import pandas
  from river import optim, utils
label_desc: Use image node_id 6 for calling the GLM obj's underlying member method code with example usage: obj._fit(x, y, w, get_grad) and returns: self