class_docstr: The abstract class for Turi Create recommender system models. This class
  defines methods common to all recommender system models, but leaves unique
  model details to separate model classes.
class_docstr_tok: ["The","abstract","class","for","Turi","Create","recommender","system","models",".","This","class","defines","methods","common","to","all","recommender","system","models",",","but","leaves","unique","model","details","to","separate","model","classes","."]
docstr: Recommend the ``k`` highest scored items based on the
  interactions given in `observed_items.`
  
  Parameters
  ----------
  observed_items : SArray, SFrame, or list
      A list/SArray of items to use to make recommendations, or
      an SFrame of items and optionally ratings and/or other
      interaction data.  The model will then recommend the most
      similar items to those given.  If ``observed_items`` has a user
      column, then it must be only one user, and the additional
      interaction data stored in the model is also used to make
      recommendations.
  
  k : int, optional
      The number of recommendations to generate.
  
  items : SArray, SFrame, or list, optional
      Restricts the items from which recommendations can be
      made. ``items`` must be an SArray, list, or SFrame with a
      single column containing items, and all recommendations
      will be made from this pool of items.  This can be used,
      for example, to restrict the recommendations to items
      within a particular category or genre. By default,
      recommendations are made from all items present when the
      model was trained.
  
  new_user_data : SFrame, optional
      ``new_user_data`` may give additional user data to the
      model.  If present, scoring is done with reference to this
      new information.  If there is any overlap with the side
      information present at training time, then this new side
      data is preferred.  Must be in the same format as the user
      data passed to ``create``.
  
  new_item_data : SFrame, optional
      ``new_item_data`` may give additional item data to the
      model.  If present, scoring is done with reference to this
      new information.  If there is any overlap with the side
      information present at training time, then this new side
      data is preferred.  Must be in the same format as the item
      data passed to ``create``.
  
  exclude : SFrame, optional
      An :class:`~turicreate.SFrame` of items or user / item
      pairs.  The column names must be equal to the user and
      item columns of the main data, and it provides the model
      with user/item pairs to exclude from the recommendations.
      These user-item-pairs are always excluded from the
      predictions, even if exclude_known is False.
  
  exclude_known : bool, optional
      By default, all user-item interactions previously seen in
      the training data, or in any new data provided using
      new_observation_data.., are excluded from the
      recommendations.  Passing in ``exclude_known = False``
      overrides this behavior.
  
  diversity : non-negative float, optional
      If given, then the recommend function attempts chooses a set
      of `k` items that are both highly scored and different from
      other items in that set. It does this by first retrieving
      ``k*(1+diversity)`` recommended items, then randomly
      choosing a diverse set from these items.  Suggested values
      for diversity are between 1 and 3.
  
  random_seed : int, optional
      If diversity is larger than 0, then some randomness is used;
      this controls the random seed to use for randomization.  If
      None, then it will be different each time.
  
  verbose : bool, optional
      If True, print the progress of generating recommendation.
  
  Returns
  -------
  out : SFrame
      A SFrame with the top ranked items for each user. The
      columns are: ``item_id``, *score*, and *rank*, where
      ``user_id`` and ``item_id`` match the user and item column
      names specified at training time.  The rank column is
      between 1 and ``k`` and gives the relative score of that
      item.  The value of score depends on the method used for
      recommendations.
  
  observed_items: list, SArray, or SFrame
docstr_tok: ["Recommend","the","``","k","``","highest","scored","items","based","on","the","interactions","given","in","`","observed_items.","`","Parameters","--","--","--","--","--","observed_items",":","SArray",",","SFrame",",","or","list","A","list\/SArray","of","items","to","use","to","make","recommendations",",","or","an","SFrame","of","items","and","optionally","ratings","and\/or","other","interaction","data",".","The","model","will","then","recommend","the","most","similar","items","to","those","given",".","If","``","observed_items","``","has","a","user","column",",","then","it","must","be","only","one","user",",","and","the","additional","interaction","data","stored","in","the","model","is","also","used","to","make","recommendations",".","k",":","int",",","optional","The","number","of","recommendations","to","generate",".","items",":","SArray",",","SFrame",",","or","list",",","optional","Restricts","the","items","from","which","recommendations","can","be","made",".","``","items","``","must","be","an","SArray",",","list",",","or","SFrame","with","a","single","column","containing","items",",","and","all","recommendations","will","be","made","from","this","pool","of","items",".","This","can","be","used",",","for","example",",","to","restrict","the","recommendations","to","items","within","a","particular","category","or","genre",".","By","default",",","recommendations","are","made","from","all","items","present","when","the","model","was","trained",".","new_user_data",":","SFrame",",","optional","``","new_user_data","``","may","give","additional","user","data","to","the","model",".","If","present",",","scoring","is","done","with","reference","to","this","new","information",".","If","there","is","any","overlap","with","the","side","information","present","at","training","time",",","then","this","new","side","data","is","preferred",".","Must","be","in","the","same","format","as","the","user","data","passed","to","``","create","``",".","new_item_data",":","SFrame",",","optional","``","new_item_data","``","may","give","additional","item","data","to","the","model",".","If","present",",","scoring","is","done","with","reference","to","this","new","information",".","If","there","is","any","overlap","with","the","side","information","present","at","training","time",",","then","this","new","side","data","is","preferred",".","Must","be","in","the","same","format","as","the","item","data","passed","to","``","create","``",".","exclude",":","SFrame",",","optional","An",":","class",":","`","~turicreate.SFrame","`","of","items","or","user","\/","item","pairs",".","The","column","names","must","be","equal","to","the","user","and","item","columns","of","the","main","data",",","and","it","provides","the","model","with","user\/item","pairs","to","exclude","from","the","recommendations",".","These","user-item-pairs","are","always","excluded","from","the","predictions",",","even","if","exclude_known","is","False",".","exclude_known",":","bool",",","optional","By","default",",","all","user-item","interactions","previously","seen","in","the","training","data",",","or","in","any","new","data","provided","using","new_observation_data","..",",","are","excluded","from","the","recommendations",".","Passing","in","``","exclude_known","=","False","``","overrides","this","behavior",".","diversity",":","non-negative","float",",","optional","If","given",",","then","the","recommend","function","attempts","chooses","a","set","of","`","k","`","items","that","are","both","highly","scored","and","different","from","other","items","in","that","set",".","It","does","this","by","first","retrieving","``","k","*","(","1+diversity",")","``","recommended","items",",","then","randomly","choosing","a","diverse","set","from","these","items",".","Suggested","values","for","diversity","are","between","1","and","3.","random_seed",":","int",",","optional","If","diversity","is","larger","than","0",",","then","some","randomness","is","used",";","this","controls","the","random","seed","to","use","for","randomization",".","If","None",",","then","it","will","be","different","each","time",".","verbose",":","bool",",","optional","If","True",",","print","the","progress","of","generating","recommendation",".","Returns","--","--","--","-","out",":","SFrame","A","SFrame","with","the","top","ranked","items","for","each","user",".","The","columns","are",":","``","item_id","``",",","*","score","*",",","and","*","rank","*",",","where","``","user_id","``","and","``","item_id","``","match","the","user","and","item","column","names","specified","at","training","time",".","The","rank","column","is","between","1","and","``","k","``","and","gives","the","relative","score","of","that","item",".","The","value","of","score","depends","on","the","method","used","for","recommendations",".","observed_items",":","list",",","SArray",",","or","SFrame"]
code: def recommend_from_interactions(
      self,
      observed_items,
      k=10,
      exclude=None,
      items=None,
      new_user_data=None,
      new_item_data=None,
      exclude_known=True,
      diversity=0,
      random_seed=None,
      verbose=True,
  ):
      """
      Recommend the ``k`` highest scored items based on the
      interactions given in `observed_items.`
  
      Parameters
      ----------
      observed_items : SArray, SFrame, or list
          A list/SArray of items to use to make recommendations, or
          an SFrame of items and optionally ratings and/or other
          interaction data.  The model will then recommend the most
          similar items to those given.  If ``observed_items`` has a user
          column, then it must be only one user, and the additional
          interaction data stored in the model is also used to make
          recommendations.
  
      k : int, optional
          The number of recommendations to generate.
  
      items : SArray, SFrame, or list, optional
          Restricts the items from which recommendations can be
          made. ``items`` must be an SArray, list, or SFrame with a
          single column containing items, and all recommendations
          will be made from this pool of items.  This can be used,
          for example, to restrict the recommendations to items
          within a particular category or genre. By default,
          recommendations are made from all items present when the
          model was trained.
  
      new_user_data : SFrame, optional
          ``new_user_data`` may give additional user data to the
          model.  If present, scoring is done with reference to this
          new information.  If there is any overlap with the side
          information present at training time, then this new side
          data is preferred.  Must be in the same format as the user
          data passed to ``create``.
  
      new_item_data : SFrame, optional
          ``new_item_data`` may give additional item data to the
          model.  If present, scoring is done with reference to this
          new information.  If there is any overlap with the side
          information present at training time, then this new side
          data is preferred.  Must be in the same format as the item
          data passed to ``create``.
  
      exclude : SFrame, optional
          An :class:`~turicreate.SFrame` of items or user / item
          pairs.  The column names must be equal to the user and
          item columns of the main data, and it provides the model
          with user/item pairs to exclude from the recommendations.
          These user-item-pairs are always excluded from the
          predictions, even if exclude_known is False.
  
      exclude_known : bool, optional
          By default, all user-item interactions previously seen in
          the training data, or in any new data provided using
          new_observation_data.., are excluded from the
          recommendations.  Passing in ``exclude_known = False``
          overrides this behavior.
  
      diversity : non-negative float, optional
          If given, then the recommend function attempts chooses a set
          of `k` items that are both highly scored and different from
          other items in that set. It does this by first retrieving
          ``k*(1+diversity)`` recommended items, then randomly
          choosing a diverse set from these items.  Suggested values
          for diversity are between 1 and 3.
  
      random_seed : int, optional
          If diversity is larger than 0, then some randomness is used;
          this controls the random seed to use for randomization.  If
          None, then it will be different each time.
  
      verbose : bool, optional
          If True, print the progress of generating recommendation.
  
      Returns
      -------
      out : SFrame
          A SFrame with the top ranked items for each user. The
          columns are: ``item_id``, *score*, and *rank*, where
          ``user_id`` and ``item_id`` match the user and item column
          names specified at training time.  The rank column is
          between 1 and ``k`` and gives the relative score of that
          item.  The value of score depends on the method used for
          recommendations.
  
      observed_items: list, SArray, or SFrame
  
      """
  
      column_types = self._get_data_schema()
      user_id = self.user_id
      item_id = self.item_id
      user_type = column_types[user_id]
      item_type = column_types[item_id]
  
      if not hasattr(self, "_implicit_user_name"):
          self._implicit_user_name = None  # ("implicit-user-%s"
      #                                        % hashlib.md5("%0.20f" % time.time()).hexdigest()[:12])
  
      if isinstance(observed_items, list):
          observed_items = _SArray(observed_items, dtype=item_type)
      if isinstance(observed_items, _SArray):
          observed_items = _SFrame({self.item_id: observed_items})
  
      if not isinstance(observed_items, _SFrame):
          raise TypeError(
              "observed_items must be a list or SArray of items, or an SFrame of items "
              "and optionally ratings or other interaction information."
          )
  
      # Don't modify the user's argument (if it's an SFrame).
      observed_items = observed_items.copy()
  
      # If a user id is present, then use that as the query user id
      # (making sure there is only one present).  If not, then use
      # the local fake user id.
      if user_id in observed_items.column_names():
          main_user_value = observed_items[user_id][0]
          if (observed_items[user_id] != main_user_value).any():
              raise ValueError(
                  "To recommend items for more than one user, use `recommend()` and "
                  "supply new interactions using new_observation_data."
              )
          users = _SArray([main_user_value], dtype=user_type)
  
      else:
          users = _SArray([self._implicit_user_name], dtype=user_type)
          observed_items[user_id] = self._implicit_user_name
  
      if observed_items[user_id].dtype != user_type:
          observed_items[user_id] = observed_items[user_id].astype(
              user_type
          )
  
      # Check the rest of the arguments.
      if exclude is not None:
          if isinstance(exclude, list):
              exclude = _SArray(exclude, dtype=item_type)
          if isinstance(exclude, _SArray):
              exclude = _SFrame({item_id: exclude})
          if user_id not in exclude.column_names():
              exclude[user_id] = self._implicit_user_name
              exclude[user_id] = exclude[user_id].astype(user_type)
  
      recommendations = self.recommend(
          users=users,
          new_observation_data=observed_items,
          exclude=exclude,
          k=k,
          items=items,
          new_user_data=new_user_data,
          new_item_data=new_item_data,
          exclude_known=exclude_known,
          diversity=diversity,
          random_seed=random_seed,
          verbose=verbose,
      )
  
      del recommendations[user_id]
  
      return recommendations
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import turicreate
  import random
  import array
  import logging
  import time
  import six
  from turicreate.toolkits import _coreml_utils
  from turicreate.toolkits._main import ToolkitError
  from turicreate.toolkits._model import Model
  from turicreate.toolkits._internal_utils import _toolkit_repr_print, _precomputed_field
  import turicreate.aggregate
  from turicreate.data_structures.sarray import SArray
  from turicreate.data_structures.sframe import SFrame
  from turicreate._deps import numpy, HAS_NUMPY
label_desc: Use image node_id 17 for calling the _Recommender obj's underlying member method code with example usage: obj.recommend_from_interactions(observed_items, k, exclude, items, new_user_data, new_item_data, exclude_known, diversity, random_seed, verbose) and returns: recommendations