class_docstr: A user-item bias rating prediction algorithm.  This implements the following
  predictor algorithm:
  
  .. math::
     s(u,i) = \mu + b_i + b_u
  
  where :math:`\mu` is the global mean rating, :math:`b_i` is item bias, and
  :math:`b_u` is the user bias.  With the provided damping values
  :math:`\beta_{\mathrm{u}}` and :math:`\beta_{\mathrm{i}}`, they are computed
  as follows:
  
  .. math::
     \begin{align*}
     \mu & = \frac{\sum_{r_{ui} \in R} r_{ui}}{|R|} &
     b_i & = \frac{\sum_{r_{ui} \in R_i} (r_{ui} - \mu)}{|R_i| + \beta_{\mathrm{i}}} &
     b_u & = \frac{\sum_{r_{ui} \in R_u} (r_{ui} - \mu - b_i)}{|R_u| + \beta_{\mathrm{u}}}
     \end{align*}
  
  The damping values can be interpreted as the number of default (mean) ratings to assume
  *a priori* for each user or item, damping low-information users and items towards a mean instead
  of permitting them to take on extreme values based on few ratings.
  
  Args:
      items: whether to compute item biases
      users: whether to compute user biases
      damping(number or tuple):
          Bayesian damping to apply to computed biases.  Either a number, to
          damp both user and item biases the same amount, or a (user,item) tuple
          providing separate damping values.
  
  Attributes:
      mean_(double): The global mean rating.
      item_offsets_(pandas.Series): The item offsets (:math:`b_i` values)
      user_offsets_(pandas.Series): The item offsets (:math:`b_u` values)
class_docstr_tok: ["A","user-item","bias","rating","prediction","algorithm",".","This","implements","the","following","predictor","algorithm",":","..","math",":",":","s","(","u",",","i",")","=","\\mu","+","b_i","+","b_u","where",":","math",":","`","\\mu","`","is","the","global","mean","rating",",",":","math",":","`","b_i","`","is","item","bias",",","and",":","math",":","`","b_u","`","is","the","user","bias",".","With","the","provided","damping","values",":","math",":","`","\\beta_","{","\\mathrm","{","u","}","}","`","and",":","math",":","`","\\beta_","{","\\mathrm","{","i","}","}","`",",","they","are","computed","as","follows",":","..","math",":",":","\\begin","{","align","*","}","\\mu","&","=","\\frac","{","\\sum_","{","r_","{","ui","}","\\in","R","}","r_","{","ui","}","}","{","|R|","}","&","b_i","&","=","\\frac","{","\\sum_","{","r_","{","ui","}","\\in","R_i","}","(","r_","{","ui","}","-","\\mu",")","}","{","|R_i|","+","\\beta_","{","\\mathrm","{","i","}","}","}","&","b_u","&","=","\\frac","{","\\sum_","{","r_","{","ui","}","\\in","R_u","}","(","r_","{","ui","}","-","\\mu","-","b_i",")","}","{","|R_u|","+","\\beta_","{","\\mathrm","{","u","}","}","}","\\end","{","align","*","}","The","damping","values","can","be","interpreted","as","the","number","of","default","(","mean",")","ratings","to","assume","*","a","priori","*","for","each","user","or","item",",","damping","low-information","users","and","items","towards","a","mean","instead","of","permitting","them","to","take","on","extreme","values","based","on","few","ratings",".","Args",":","items",":","whether","to","compute","item","biases","users",":","whether","to","compute","user","biases","damping","(","number","or","tuple",")",":","Bayesian","damping","to","apply","to","computed","biases",".","Either","a","number",",","to","damp","both","user","and","item","biases","the","same","amount",",","or","a","(","user",",","item",")","tuple","providing","separate","damping","values",".","Attributes",":","mean_","(","double",")",":","The","global","mean","rating",".","item_offsets_","(","pandas.Series",")",":","The","item","offsets","(",":","math",":","`","b_i","`","values",")","user_offsets_","(","pandas.Series",")",":","The","item","offsets","(",":","math",":","`","b_u","`","values",")"]
code: def __init__(self, items=True, users=True, damping=0.0):
      self.items = items
      self.users = users
      if isinstance(damping, tuple):
          self.damping = damping
          self.user_damping, self.item_damping = damping
      else:
          self.damping = damping
          self.user_damping = damping
          self.item_damping = damping
  
      if self.user_damping < 0:
          raise ValueError("user damping must be non-negative")
      if self.item_damping < 0:
          raise ValueError("item damping must be non-negative")
  
file_path: lkpy/lenskit/algorithms/bias.py
imports: import logging
  import pandas
  from .None import Predictor
label_desc: Use image node_id 1 to create a new Bias object from inherited base classes: Predictor with example: obj = Bias(items, users, damping)