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.
code: def __init__(
      self,
      nnbrs,
      min_nbrs=1,
      min_sim=1.0e-6,
      save_nbrs=None,
      feedback="explicit",
      **kwargs,
  ):
      self.nnbrs = nnbrs
      if self.nnbrs is not None and self.nnbrs < 1:
          self.nnbrs = -1
      self.min_nbrs = min_nbrs
      if self.min_nbrs is not None and self.min_nbrs < 1:
          self.min_nbrs = 1
      self.min_sim = min_sim
      self.save_nbrs = save_nbrs
  
      if feedback == "explicit":
          defaults = {
              "center": True,
              "aggregate": self.AGG_WA,
              "use_ratings": True,
          }
      elif feedback == "implicit":
          defaults = {
              "center": False,
              "aggregate": self.AGG_SUM,
              "use_ratings": False,
          }
      else:
          raise ValueError(f"invalid feedback mode: {feedback}")
  
      defaults.update(kwargs)
      self.center = defaults["center"]
      self.aggregate = intern(defaults["aggregate"])
      self.use_ratings = defaults["use_ratings"]
  
      self._check_setup()
  
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 1 to create a new ItemItem object from inherited base classes: Predictor with example: obj = ItemItem(nnbrs, min_nbrs, min_sim, save_nbrs, feedback)