class_docstr: Item-item nearest-neighbor collaborative filtering with ratings. This item-item implementation
  is not terribly configurable; it hard-codes design decisions found to work well in the previous
  Java-based LensKit code :cite:p:`Ekstrand2011-bp`.  This implementation is based on the description
  of item-based CF by :cite:t:`Deshpande2004-ht`, and produces results equivalent to Java LensKit.
  
  The k-NN predictor supports several aggregate functions:
  
  ``weighted-average``
      The weighted average of the user's rating values, using item-item similarities as
      weights.
  
  ``sum``
      The sum of the similarities between the target item and the user's rated items,
      regardless of the rating the user gave the items.
  
  Args:
      nnbrs(int):
          the maximum number of neighbors for scoring each item (``None`` for unlimited)
      min_nbrs(int): the minimum number of neighbors for scoring each item
      min_sim(float): minimum similarity threshold for considering a neighbor
      save_nbrs(float):
          the number of neighbors to save per item in the trained model
          (``None`` for unlimited)
      feedback(str):
          Control how feedback should be interpreted.  Specifies defaults for the other
          settings, which can be overridden individually; can be one of the following values:
  
          ``explicit``
              Configure for explicit-feedback mode: use rating values, center ratings, and
              use the ``weighted-average`` aggregate method for prediction.  This is the
              default setting.
  
          ``implicit``
              Configure for implicit-feedback mode: ignore rating values, do not center ratings,
              and use the ``sum`` aggregate method for prediction.
      center(bool):
          whether to normalize (mean-center) rating vectors prior to computing similarities
          and aggregating user rating values.  Defaults to ``True``; turn this off when working
          with unary data and other data types that don't respond well to centering.
      aggregate(str):
          the type of aggregation to do. Can be ``weighted-average`` (the default) or ``sum``.
      use_ratings(bool):
          whether or not to use the rating values. If ``False``, it ignores rating values and
          considers an implicit feedback signal of 1 for every (user,item) pair present.
  
  Attributes:
      item_index_(pandas.Index): the index of item IDs.
      item_means_(numpy.ndarray): the mean rating for each known item.
      item_counts_(numpy.ndarray): the number of saved neighbors for each item.
      sim_matrix_(matrix.CSR): the similarity matrix.
      user_index_(pandas.Index): the index of known user IDs for the rating matrix.
      rating_matrix_(matrix.CSR): the user-item rating matrix for looking up users' ratings.
docstr: Train a model.
  
  The model-training process depends on ``save_nbrs`` and ``min_sim``, but *not* on other
  algorithm parameters.
  
  Args:
      ratings(pandas.DataFrame):
          (user,item,rating) data for computing item similarities.
docstr_tok: ["Train","a","model",".","The","model-training","process","depends","on","``","save_nbrs","``","and","``","min_sim","``",",","but","*","not","*","on","other","algorithm","parameters",".","Args",":","ratings","(","pandas.DataFrame",")",":","(","user",",","item",",","rating",")","data","for","computing","item","similarities","."]
code: def fit(self, ratings, **kwargs):
      """
      Train a model.
  
      The model-training process depends on ``save_nbrs`` and ``min_sim``, but *not* on other
      algorithm parameters.
  
      Args:
          ratings(pandas.DataFrame):
              (user,item,rating) data for computing item similarities.
      """
      util.check_env()
      # Training proceeds in 2 steps:
      # 1. Normalize item vectors to be mean-centered and unit-normalized
      # 2. Compute similarities with pairwise dot products
      self._timer = util.Stopwatch()
  
      _logger.debug(
          "[%s] beginning fit, memory use %s",
          self._timer,
          util.max_memory(),
      )
      _logger.debug("[%s] using CSR kernel %s", self._timer, csrk.name)
  
      init_rmat, users, items = sparse_ratings(ratings)
      n_items = len(items)
      _logger.info(
          "[%s] made sparse matrix for %d items (%d ratings from %d users)",
          self._timer,
          len(items),
          init_rmat.nnz,
          len(users),
      )
      _logger.debug(
          "[%s] made matrix, memory use %s",
          self._timer,
          util.max_memory(),
      )
  
      rmat, item_means = self._mean_center(ratings, init_rmat, items)
      _logger.debug(
          "[%s] centered, memory use %s", self._timer, util.max_memory()
      )
  
      rmat = self._normalize(rmat)
      _logger.debug(
          "[%s] normalized, memory use %s",
          self._timer,
          util.max_memory(),
      )
  
      _logger.info("[%s] computing similarity matrix", self._timer)
      smat = self._compute_similarities(rmat)
      _logger.debug(
          "[%s] computed, memory use %s", self._timer, util.max_memory()
      )
  
      _logger.info(
          "[%s] got neighborhoods for %d of %d items",
          self._timer,
          np.sum(np.diff(smat.rowptrs) > 0),
          n_items,
      )
  
      _logger.info(
          "[%s] computed %d neighbor pairs", self._timer, smat.nnz
      )
  
      self.item_index_ = items
      self.item_means_ = item_means
      self.item_counts_ = np.diff(smat.rowptrs)
      self.sim_matrix_ = smat
      self.user_index_ = users
      self.rating_matrix_ = init_rmat
      # create an inverted similarity matrix for efficient scanning
      self._sim_inv_ = smat.transpose()
      _logger.info(
          "[%s] transposed matrix for optimization", self._timer
      )
      _logger.debug(
          "[%s] done, memory use %s", self._timer, util.max_memory()
      )
  
      return self
  
imports: from sys import intern
  import logging
  import warnings
  import pandas
  import numpy
  import scipy.sparse
  import scipy.sparse.linalg
  from csr import CSR, create_from_sizes, create_empty
  import csr.kernel
  from numba import njit, prange
  from numba.typed import List
  from lenskit import util, DataWarning, ConfigWarning
  from lenskit.data import sparse_ratings
  from lenskit.sharing import in_share_context
  from lenskit.util.parallel import is_mp_worker
  from lenskit.util.accum import kvp_minheap_insert, kvp_minheap_sort
  from .None import Predictor
label_desc: Use image node_id 3 for calling the ItemItem obj's underlying member method code with example usage: obj.fit(ratings) and returns: self