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: Train an algorithm on a given training set.
  
  This method is called by every derived class as the first basic step
  for training an algorithm. It basically just initializes some internal
  structures and set the self.trainset attribute.
  
  Args:
      trainset(:obj:`Trainset <surprise.Trainset>`) : A training
          set, as returned by the :meth:`folds
          <surprise.dataset.Dataset.folds>` method.
  
  Returns:
      self
docstr_tok: ["Train","an","algorithm","on","a","given","training","set",".","This","method","is","called","by","every","derived","class","as","the","first","basic","step","for","training","an","algorithm",".","It","basically","just","initializes","some","internal","structures","and","set","the","self.trainset","attribute",".","Args",":","trainset","(",":","obj",":","`","Trainset","<","surprise.Trainset",">","`",")",":","A","training","set",",","as","returned","by","the",":","meth",":","`","folds","<","surprise.dataset.Dataset.folds",">","`","method",".","Returns",":","self"]
code: def fit(self, trainset):
      """Train an algorithm on a given training set.
  
      This method is called by every derived class as the first basic step
      for training an algorithm. It basically just initializes some internal
      structures and set the self.trainset attribute.
  
      Args:
          trainset(:obj:`Trainset <surprise.Trainset>`) : A training
              set, as returned by the :meth:`folds
              <surprise.dataset.Dataset.folds>` method.
  
      Returns:
          self
      """
  
      self.trainset = trainset
  
      # (re) Initialise baselines
      self.bu = self.bi = None
  
      return self
  
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 2 for calling the AlgoBase obj's underlying member method code with example usage: obj.fit(trainset) and returns: self