class_docstr: Algorithm class implementing FunkSVD matrix factorization.  FunkSVD is a regularized
  biased matrix factorization technique trained with featurewise stochastic gradient
  descent.
  
  See the base class :class:`.MFPredictor` for documentation on the estimated parameters
  you can extract from a trained model.
  
  Args:
      features(int): the number of features to train
      iterations(int): the number of iterations to train each feature
      lrate(double): the learning rate
      reg(double): the regularization factor
      damping(double): damping factor for the underlying mean
      bias(Predictor): the underlying bias model to fit.  If ``True``, then a
          :py:class:`.bias.Bias` model is fit with ``damping``.
      range(tuple):
          the ``(min, max)`` rating values to clamp ratings, or ``None`` to leave
          predictions unclamped.
      random_state:
          The random state for shuffling the data prior to training.
docstr: Train a FunkSVD model.
  
  Args:
      ratings: the ratings data frame.
docstr_tok: ["Train","a","FunkSVD","model",".","Args",":","ratings",":","the","ratings","data","frame","."]
code: def fit(self, ratings, **kwargs):
      """
      Train a FunkSVD model.
  
      Args:
          ratings: the ratings data frame.
      """
      util.check_env()
      timer = util.Stopwatch()
      if "rating" not in ratings:
          _logger.warning(
              "no rating column found, assuming rating values of 1.0"
          )
          ratings = ratings.assign(rating=1.0)
  
      if self.bias:
          _logger.info("[%s] fitting bias model", timer)
          self.bias.fit(ratings)
  
      _logger.info(
          "[%s] preparing rating data for %d samples",
          timer,
          len(ratings),
      )
      _logger.debug("shuffling rating data")
      shuf = np.arange(len(ratings), dtype=np.int_)
      self.random.shuffle(shuf)
      ratings = ratings.iloc[shuf, :]
  
      _logger.debug("[%s] indexing users and items", timer)
      uidx = pd.Index(ratings.user.unique())
      iidx = pd.Index(ratings.item.unique())
  
      users = uidx.get_indexer(ratings.user).astype(np.int32)
      assert np.all(users >= 0)
      items = iidx.get_indexer(ratings.item).astype(np.int32)
      assert np.all(items >= 0)
  
      _logger.debug("[%s] computing initial estimates", timer)
      if self.bias:
          initial = pd.Series(
              self.bias.mean_, index=ratings.index, dtype=np.float_
          )
          ibias, initial = _align_add_bias(
              self.bias.item_offsets_, iidx, ratings.item, initial
          )
          ubias, initial = _align_add_bias(
              self.bias.user_offsets_, uidx, ratings.user, initial
          )
      else:
          initial = pd.Series(0.0, index=ratings.index)
  
      _logger.debug(
          "have %d estimates for %d ratings", len(initial), len(ratings)
      )
      assert len(initial) == len(ratings)
  
      _logger.debug("[%s] initializing data structures", timer)
      context = Context(
          users,
          items,
          ratings.rating.astype(np.float_).values,
          initial.values,
      )
      params = make_params(
          self.iterations, self.lrate, self.reg, self.range
      )
  
      model = _fresh_model(self.features, len(uidx), len(iidx))
  
      _logger.info(
          "[%s] training biased MF model with %d features",
          timer,
          self.features,
      )
      train(context, params, model, timer)
      _logger.info("finished model training in %s", timer)
  
      self.user_index_ = uidx
      self.item_index_ = iidx
      self.user_features_ = model.user_features
      self.item_features_ = model.item_features
  
      return self
  
imports: import logging
  import time
  import pandas
  import numpy
  import numba
  from seedbank import numpy_rng
  from .bias import Bias
  from .mf_common import MFPredictor
  from ..None import util
label_desc: Use image node_id 2 for calling the FunkSVD obj's underlying member method code with example usage: obj.fit(ratings) and returns: self