recommend(self, users=None, k=10, exclude=None, items=None, new_observation_data=None, new_user_data=None, new_item_data=None, exclude_known=True, diversity=0, random_seed=None, verbose=True)¶
khighest scored items for each user.
- users : SArray, SFrame, or list, optional
Users or observation queries for which to make recommendations. For list, SArray, and single-column inputs, this is simply a set of user IDs. By default, recommendations are returned for all users present when the model was trained. However, if the recommender model was created with additional features in the
observation_dataSFrame, then a corresponding SFrame of observation queries – observation data without item or target columns – can be passed to this method. For example, a model trained with user ID, item ID, time, and rating columns may be queried using an SFrame with user ID and time columns. In this case, the user ID column must be present, and all column names should match those in the
observation_dataSFrame passed to
- k : int, optional
The number of recommendations to generate for each user.
- items : SArray, SFrame, or list, optional
Restricts the items from which recommendations can be made. If
itemsis an SArray, list, or SFrame with a single column, only items from the given set will be recommended. This can be used, for example, to restrict the recommendations to items within a particular category or genre. If
itemsis an SFrame with user ID and item ID columns, then the item restriction is specialized to each user. For example, if
itemscontains 3 rows with user U1 – (U1, I1), (U1, I2), and (U1, I3) – then the recommendations for user U1 are chosen from items I1, I2, and I3. By default, recommendations are made from all items present when the model was trained.
- new_observation_data : SFrame, optional
new_observation_datagives additional observation data to the model, which may be used by the models to improve score and recommendation accuracy. Must be in the same format as the observation data passed to
create. How this data is used varies by model.
- new_user_data : SFrame, optional
new_user_datamay 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
- new_item_data : SFrame, optional
new_item_datamay 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
- exclude : SFrame, optional
SFrameof 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 = Falseoverrides 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, will be different each time.
- verbose : bool, optional
If True, print the progress of generating recommendation.
- out : SFrame
A SFrame with the top ranked items for each user. The columns are:
item_id, score, and rank, where
item_idmatch the user and item column names specified at training time. The rank column is between 1 and
kand gives the relative score of that item. The value of score depends on the method used for recommendations.