class_docstr: Baseline for recommender systems.
  
  A first-order approximation of the bias involved in target. The model equation is defined as:
  
  $$\hat{y}(x) = \bar{y} + bu_{u} + bi_{i}$$
  
  Where $bu_{u}$ and $bi_{i}$ are respectively the user and item biases.
  
  This model expects a dict input with a `user` and an `item` entries without any type constraint
  on their values (i.e. can be strings or numbers). Other entries are ignored.
  
  Parameters
  ----------
  optimizer
      The sequential optimizer used for updating the weights.
  loss
      The loss function to optimize for.
  l2
      regularization amount used to push weights towards 0.
  initializer
      Weights initialization scheme.
  clip_gradient
      Clips the absolute value of each gradient value.
  seed
      Random number generation seed. Set this for reproducibility.
  
  Attributes
  ----------
  global_mean : stats.Mean
      The target arithmetic mean.
  u_biases : collections.defaultdict
      The user bias weights.
  i_biases : collections.defaultdict
      The item bias weights.
  u_optimizer : optim.base.Optimizer
      The sequential optimizer used for updating the user bias weights.
  i_optimizer : optim.base.Optimizer
      The sequential optimizer used for updating the item bias weights.
  
  Examples
  --------
  
  >>> from river import optim
  >>> from river import reco
  
  >>> dataset = (
  ...     ({'user': 'Alice', 'item': 'Superman'}, 8),
  ...     ({'user': 'Alice', 'item': 'Terminator'}, 9),
  ...     ({'user': 'Alice', 'item': 'Star Wars'}, 8),
  ...     ({'user': 'Alice', 'item': 'Notting Hill'}, 2),
  ...     ({'user': 'Alice', 'item': 'Harry Potter'}, 5),
  ...     ({'user': 'Bob', 'item': 'Superman'}, 8),
  ...     ({'user': 'Bob', 'item': 'Terminator'}, 9),
  ...     ({'user': 'Bob', 'item': 'Star Wars'}, 8),
  ...     ({'user': 'Bob', 'item': 'Notting Hill'}, 2)
  ... )
  
  >>> model = reco.Baseline(optimizer=optim.SGD(0.005))
  
  >>> for x, y in dataset:
  ...     model.learn_one(**x, y=y)
  
  >>> model.predict_one(user='Bob', item='Harry Potter')
  6.538120
  
  References
  ----------
  [^1]: [Matrix factorization techniques for recommender systems](https://datajobs.com/data-science-repo/Recommender-Systems-[Netflix].pdf)
code: def __init__(
      self,
      optimizer: optim.base.Optimizer | None = None,
      loss: optim.losses.Loss | None = None,
      l2=0.0,
      initializer: optim.initializers.Initializer | None = None,
      clip_gradient=1e12,
      seed=None,
  ):
      super().__init__(seed=seed)
  
      self.optimizer = (
          optim.SGD() if optimizer is None else copy.deepcopy(optimizer)
      )
      self.u_optimizer = (
          optim.SGD() if optimizer is None else copy.deepcopy(optimizer)
      )
      self.i_optimizer = (
          optim.SGD() if optimizer is None else copy.deepcopy(optimizer)
      )
      self.loss = optim.losses.Squared() if loss is None else loss
      self.l2 = l2
  
      if initializer is None:
          initializer = optim.initializers.Zeros()
      self.initializer = initializer
  
      self.clip_gradient = clip_gradient
      self.global_mean = stats.Mean()
      self.u_biases: collections.defaultdict[
          int, optim.initializers.Initializer
      ] = collections.defaultdict(initializer)
      self.i_biases: collections.defaultdict[
          int, optim.initializers.Initializer
      ] = collections.defaultdict(initializer)
  
file_path: river/river/reco/baseline.py
imports: from __future__ import annotations
  import collections
  import copy
  from river import optim, reco, stats, utils
label_desc: Use image node_id 1 to create a new Baseline object from inherited base classes: reco.base with example: obj = Baseline(optimizer, loss, l2, initializer, clip_gradient, seed)