class_docstr: Abstract class where is defined the basic behavior of a prediction
  algorithm.
  
  Keyword Args:
      baseline_options(dict, optional): If the algorithm needs to compute a
          baseline estimate, the ``baseline_options`` parameter is used to
          configure how they are computed. See
          :ref:`baseline_estimates_configuration` for usage.
class_docstr_tok: ["Abstract","class","where","is","defined","the","basic","behavior","of","a","prediction","algorithm",".","Keyword","Args",":","baseline_options","(","dict",",","optional",")",":","If","the","algorithm","needs","to","compute","a","baseline","estimate",",","the","``","baseline_options","``","parameter","is","used","to","configure","how","they","are","computed",".","See",":","ref",":","`","baseline_estimates_configuration","`","for","usage","."]
docstr: Compute users and items baselines.
  
  The way baselines are computed depends on the ``bsl_options`` parameter
  passed at the creation of the algorithm (see
  :ref:`baseline_estimates_configuration`).
  
  This method is only relevant for algorithms using :func:`Pearson
  baseline similarity<surprise.similarities.pearson_baseline>` or the
  :class:`BaselineOnly
  <surprise.prediction_algorithms.baseline_only.BaselineOnly>` algorithm.
  
  Returns:
      A tuple ``(bu, bi)``, which are users and items baselines.
docstr_tok: ["Compute","users","and","items","baselines",".","The","way","baselines","are","computed","depends","on","the","``","bsl_options","``","parameter","passed","at","the","creation","of","the","algorithm","(","see",":","ref",":","`","baseline_estimates_configuration","`",")",".","This","method","is","only","relevant","for","algorithms","using",":","func",":","`","Pearson","baseline","similarity","<","surprise.similarities.pearson_baseline",">","`","or","the",":","class",":","`","BaselineOnly","<","surprise.prediction_algorithms.baseline_only.BaselineOnly",">","`","algorithm",".","Returns",":","A","tuple","``","(","bu",",","bi",")","``",",","which","are","users","and","items","baselines","."]
code: def compute_baselines(self):
      """Compute users and items baselines.
  
      The way baselines are computed depends on the ``bsl_options`` parameter
      passed at the creation of the algorithm (see
      :ref:`baseline_estimates_configuration`).
  
      This method is only relevant for algorithms using :func:`Pearson
      baseline similarity<surprise.similarities.pearson_baseline>` or the
      :class:`BaselineOnly
      <surprise.prediction_algorithms.baseline_only.BaselineOnly>` algorithm.
  
      Returns:
          A tuple ``(bu, bi)``, which are users and items baselines."""
  
      # Firt of, if this method has already been called before on the same
      # trainset, then just return. Indeed, compute_baselines may be called
      # more than one time, for example when a similarity metric (e.g.
      # pearson_baseline) uses baseline estimates.
      if self.bu is not None:
          return self.bu, self.bi
  
      method = dict(als=baseline_als, sgd=baseline_sgd)
  
      method_name = self.bsl_options.get("method", "als")
  
      try:
          if getattr(self, "verbose", False):
              print("Estimating biases using", method_name + "...")
          self.bu, self.bi = method[method_name](self)
          return self.bu, self.bi
      except KeyError:
          raise ValueError(
              "Invalid method "
              + method_name
              + " for baseline computation."
              + " Available methods are als and sgd."
          )
  
file_path: Surprise/surprise/prediction_algorithms/algo_base.py
imports: import heapq
  from ..None import similarities
  from .optimize_baselines import baseline_als, baseline_sgd
  from .predictions import Prediction, PredictionImpossible
label_desc: Use image node_id 6 for calling the AlgoBase obj's underlying member method code with example usage: obj.compute_baselines() and returns: self,  self, self,  self