class_docstr: Defines a common interface for all recommendation models
class_docstr_tok: ["Defines","a","common","interface","for","all","recommendation","models"]
docstr: Recommends items for users.
  
  This method allows you to calculate the top N recommendations for a user or
  batch of users. Passing an array of userids instead of a single userid will
  tend to be more efficient, and allows multi-thread processing on the CPU.
  
  This method has options for filtering out items from the results. You can both
  filter out items that have already been liked by the user with the
  filter_already_liked_items parameter, as well as pass in filter_items to filter
  out other items for all users in the batch. By default all items in the training
  dataset are scored, but by setting the 'items' parameter you can restrict down to
  a subset.
  
  Example usage::
  
      # calculate the top recommendations for a single user
      ids, scores = model.recommend(0, user_items[0])
  
      # calculate the top recommendations for a batch of users
      userids = np.arange(10)
      ids, scores = model.recommend(userids, user_items[userids])
  
  Parameters
  ----------
  userid : Union[int, array_like]
      The userid or array of userids to calculate recommendations for
  user_items : csr_matrix
      A sparse matrix of shape (users, number_items). This lets us look
      up the liked items and their weights for the user. This is used to filter out
      items that have already been liked from the output, and to also potentially
      recalculate the user representation. Each row in this sparse matrix corresponds
      to a row in the userid parameter: that is the first row in this matrix contains
      the liked items for the first user in the userid array.
  N : int, optional
      The number of results to return
  filter_already_liked_items: bool, optional
      When true, don't return items present in the training set that were rated
      by the specified user.
  filter_items : array_like, optional
      List of extra item ids to filter out from the output
  recalculate_user : bool, optional
      When true, don't rely on stored user embeddings and instead recalculate from the
      passed in user_items. This option isn't supported by all models.
  items: array_like, optional
      Array of extra item ids. When set this will only rank the items in this array instead
      of ranking every item the model was fit for. This parameter cannot be used with
      filter_items
  
  Returns
  -------
  tuple
      Tuple of (itemids, scores) arrays. When calculating for a single user these array will
      be 1-dimensional with N items. When passed an array of userids, these will be
      2-dimensional arrays with a row for each user.
docstr_tok: ["Recommends","items","for","users",".","This","method","allows","you","to","calculate","the","top","N","recommendations","for","a","user","or","batch","of","users",".","Passing","an","array","of","userids","instead","of","a","single","userid","will","tend","to","be","more","efficient",",","and","allows","multi-thread","processing","on","the","CPU",".","This","method","has","options","for","filtering","out","items","from","the","results",".","You","can","both","filter","out","items","that","have","already","been","liked","by","the","user","with","the","filter_already_liked_items","parameter",",","as","well","as","pass","in","filter_items","to","filter","out","other","items","for","all","users","in","the","batch",".","By","default","all","items","in","the","training","dataset","are","scored",",","but","by","setting","the","'items","'","parameter","you","can","restrict","down","to","a","subset",".","Example","usage",":",":","#","calculate","the","top","recommendations","for","a","single","user","ids",",","scores","=","model.recommend","(","0",",","user_items","[","0","]",")","#","calculate","the","top","recommendations","for","a","batch","of","users","userids","=","np.arange","(","10",")","ids",",","scores","=","model.recommend","(","userids",",","user_items","[","userids","]",")","Parameters","--","--","--","--","--","userid",":","Union","[","int",",","array_like","]","The","userid","or","array","of","userids","to","calculate","recommendations","for","user_items",":","csr_matrix","A","sparse","matrix","of","shape","(","users",",","number_items",")",".","This","lets","us","look","up","the","liked","items","and","their","weights","for","the","user",".","This","is","used","to","filter","out","items","that","have","already","been","liked","from","the","output",",","and","to","also","potentially","recalculate","the","user","representation",".","Each","row","in","this","sparse","matrix","corresponds","to","a","row","in","the","userid","parameter",":","that","is","the","first","row","in","this","matrix","contains","the","liked","items","for","the","first","user","in","the","userid","array",".","N",":","int",",","optional","The","number","of","results","to","return","filter_already_liked_items",":","bool",",","optional","When","true",",","do","n't","return","items","present","in","the","training","set","that","were","rated","by","the","specified","user",".","filter_items",":","array_like",",","optional","List","of","extra","item","ids","to","filter","out","from","the","output","recalculate_user",":","bool",",","optional","When","true",",","do","n't","rely","on","stored","user","embeddings","and","instead","recalculate","from","the","passed","in","user_items",".","This","option","is","n't","supported","by","all","models",".","items",":","array_like",",","optional","Array","of","extra","item","ids",".","When","set","this","will","only","rank","the","items","in","this","array","instead","of","ranking","every","item","the","model","was","fit","for",".","This","parameter","can","not","be","used","with","filter_items","Returns","--","--","--","-","tuple","Tuple","of","(","itemids",",","scores",")","arrays",".","When","calculating","for","a","single","user","these","array","will","be","1-dimensional","with","N","items",".","When","passed","an","array","of","userids",",","these","will","be","2-dimensional","arrays","with","a","row","for","each","user","."]
code: def recommend(
      self,
      userid,
      user_items,
      N=10,
      filter_already_liked_items=True,
      filter_items=None,
      recalculate_user=False,
      items=None,
  ):
      """
      Recommends items for users.
  
      This method allows you to calculate the top N recommendations for a user or
      batch of users. Passing an array of userids instead of a single userid will
      tend to be more efficient, and allows multi-thread processing on the CPU.
  
      This method has options for filtering out items from the results. You can both
      filter out items that have already been liked by the user with the
      filter_already_liked_items parameter, as well as pass in filter_items to filter
      out other items for all users in the batch. By default all items in the training
      dataset are scored, but by setting the 'items' parameter you can restrict down to
      a subset.
  
      Example usage::
  
          # calculate the top recommendations for a single user
          ids, scores = model.recommend(0, user_items[0])
  
          # calculate the top recommendations for a batch of users
          userids = np.arange(10)
          ids, scores = model.recommend(userids, user_items[userids])
  
      Parameters
      ----------
      userid : Union[int, array_like]
          The userid or array of userids to calculate recommendations for
      user_items : csr_matrix
          A sparse matrix of shape (users, number_items). This lets us look
          up the liked items and their weights for the user. This is used to filter out
          items that have already been liked from the output, and to also potentially
          recalculate the user representation. Each row in this sparse matrix corresponds
          to a row in the userid parameter: that is the first row in this matrix contains
          the liked items for the first user in the userid array.
      N : int, optional
          The number of results to return
      filter_already_liked_items: bool, optional
          When true, don't return items present in the training set that were rated
          by the specified user.
      filter_items : array_like, optional
          List of extra item ids to filter out from the output
      recalculate_user : bool, optional
          When true, don't rely on stored user embeddings and instead recalculate from the
          passed in user_items. This option isn't supported by all models.
      items: array_like, optional
          Array of extra item ids. When set this will only rank the items in this array instead
          of ranking every item the model was fit for. This parameter cannot be used with
          filter_items
  
      Returns
      -------
      tuple
          Tuple of (itemids, scores) arrays. When calculating for a single user these array will
          be 1-dimensional with N items. When passed an array of userids, these will be
          2-dimensional arrays with a row for each user.
      """
  
file_path: implicit/implicit/recommender_base.py
imports: import warnings
  from abc import ABCMeta, abstractmethod
  import numpy
label_desc: Use image node_id 2 for calling the RecommenderBase obj's underlying member method code with example usage: obj.recommend(userid, user_items, N, filter_already_liked_items, filter_items, recalculate_user, items) without return types