class_docstr: MatrixFactorizationBase contains common functionality for recommendation models.
  
  Attributes
  ----------
  item_factors : ndarray
      Array of latent factors for each item in the training set
  user_factors : ndarray
      Array of latent factors for each user in the training set
  num_threads : int
      The number of threads to use for batch recommendation calls and fitting the
      model. Setting to 0 will use all CPU cores on the machine
class_docstr_tok: ["MatrixFactorizationBase","contains","common","functionality","for","recommendation","models",".","Attributes","--","--","--","--","--","item_factors",":","ndarray","Array","of","latent","factors","for","each","item","in","the","training","set","user_factors",":","ndarray","Array","of","latent","factors","for","each","user","in","the","training","set","num_threads",":","int","The","number","of","threads","to","use","for","batch","recommendation","calls","and","fitting","the","model",".","Setting","to","0","will","use","all","CPU","cores","on","the","machine"]
code: def recommend(
      self,
      userid,
      user_items,
      N=10,
      filter_already_liked_items=True,
      filter_items=None,
      recalculate_user=False,
      items=None,
  ):
      if filter_already_liked_items or recalculate_user:
          if not isinstance(user_items, csr_matrix):
              raise ValueError(
                  "user_items needs to be a CSR sparse matrix"
              )
          user_count = 1 if np.isscalar(userid) else len(userid)
          if user_items.shape[0] != user_count:
              raise ValueError(
                  "user_items must contain 1 row for every user in userids"
              )
  
      user = self._user_factor(userid, user_items, recalculate_user)
  
      item_factors = self.item_factors
  
      # if we have an item list to restrict down to, we need to filter the item_factors
      # and filter_query_items
      if items is not None:
          N = min(N, len(items))
          if filter_items:
              raise ValueError(
                  "Can't set both items and filter_items in recommend call"
              )
  
          items = np.array(items)
          items.sort()
          item_factors = item_factors[items]
  
          # check selected items are in the model
          if (
              items.max() >= self.item_factors.shape[0]
              or items.min() < 0
          ):
              raise IndexError(
                  "Some itemids in the items parameter in are not in the model"
              )
  
      # get a CSR matrix of items to filter per-user
      filter_query_items = None
      if filter_already_liked_items:
          filter_query_items = user_items
  
          # if we've been given a list of explicit itemids to rank, we need to filter down
          if items is not None:
              filter_query_items = _filter_items_from_sparse_matrix(
                  items, filter_query_items
              )
  
      ids, scores = topk(
          item_factors,
          user,
          N,
          filter_query_items=filter_query_items,
          filter_items=filter_items,
          num_threads=self.num_threads,
      )
  
      if np.isscalar(userid):
          ids, scores = ids[0], scores[0]
  
      # if we've been given an explicit items list, remap the ids
      if items is not None:
          ids = items[ids]
  
      return ids, scores
  
imports: import warnings
  import numpy
  from scipy.sparse import csr_matrix, lil_matrix
  from ..recommender_base import ModelFitError, RecommenderBase
  from .topk import topk
label_desc: Use image node_id 2 for calling the MatrixFactorizationBase obj's underlying member method code with example usage: obj.recommend(userid, user_items, N, filter_already_liked_items, filter_items, recalculate_user, items) and returns: ids,  scores