Getting real-time item recommendations
You can get real-time item recommendations from an Amazon Personalize recommender or custom campaign with the Amazon Personalize console, Amazon Command Line Interface (Amazon CLI), or Amazon SDKs.
Topics
Getting item recommendations (console)
To get recommendations with the Amazon Personalize console, you provide the request information on the details page of either a recommender (Domain dataset group) or a custom campaign.
To get recommendations
-
Open the Amazon Personalize console at https://console.amazonaws.cn/personalize/home
and sign into your account. -
Choose the dataset group that contains the campaign or recommender you are using.
-
In the navigation pane, choose Campaigns or Recommenders.
-
Choose the target campaign or recommender.
-
For a campaigns, under Test campaign results, enter your recommendation request details based on the recipe you used. For a recommenders choose Test recommender and enter your recommendation request details based on your use case.
If you recorded events for a user before they logged in (an anonymous user), you can get recommendations for this user by providing the
sessionId
from those events as if it is theiruserId
. For more information about recording events for anonymous users, see Recording events for anonymous users. -
Optionally choose a filter. For more information, see Filtering recommendations and user segments.
-
If you use contextual metadata, provide data for each context. For each context, for the Key enter the metadata field. For the Value enter the context data. For more information, see Increasing recommendation relevance with contextual metadata.
-
If you enabled metadata in recommendations for your campaign or recommender, for Items dataset columns, choose the metadata columns that you want to include in recommendation results. For information about enabling metadata for a campaign, see Item metadata in recommendations. For information about enabling metadata for a recommender, see Enabling metadata in recommendations for a domain recommender in Amazon Personalize.
-
If you want to promote a subset of items, optionally complete the Promotion fields. For more information see Promoting items in real-time recommendations.
-
Choose Get recommendations. A table containing the user’s top 25 recommended items displays. If you use User-Personalization-v2, each recommended item includes a list of reasons for why the item was included in recommendations. For more information, see Recommendation reasons with User-Personalization-v2.
Getting item recommendations (Amazon CLI)
Use the following code to get recommendations from a campaign. To get recommendations from a recommender, replace the
campaign-arn
parameter with the recommender-arn
.
Specify the ID of the user you want to get recommendations for, and the Amazon Resource Name (ARN) of your campaign or recommender. A list of the top 10 recommended items for the user displays. If you use User-Personalization-v2, each recommended item includes a list of reasons for why the item was included in recommendations. For more information, see Recommendation reasons with User-Personalization-v2.
To change the number of recommended items, change the value for numResults
. The default is 25 items. The
maximum is 500 items. If you used a RELATED_ITEMS recipe to train the solution version backing the campaign, replace the
user-id
parameter with item-id
and specify the item ID.
If you recorded events for a user before they logged in (an anonymous user), you can get recommendations for this user by providing the sessionId
from those events
as if it is their userId
. For more information about recording events for anonymous users, see Recording events for
anonymous users.
aws personalize-runtime get-recommendations \ --campaign-arn
campaign arn
\ --user-idUser ID
\ --num-results 10
Getting item recommendations (Amazon SDKs)
The following code shows how to get Amazon Personalize recommendations for a user from a campaign with the Amazon SDKs. To get
recommendations from a recommender, replace the campaignArn
parameter with the recommenderArn
.
Specify the ID of the user you want to get recommendations for, and the Amazon Resource Name (ARN) of your campaign or recommender. A list of the top 10 recommended items for the user displays. If you use User-Personalization-v2, each recommended item includes a list of reasons for why the item was included in recommendations. For more information, see Recommendation reasons with User-Personalization-v2.
To change the number of recommended items, change the value for numResults
. The default is 25 items. The
maximum is 500 items. If you used a RELATED_ITEMS recipe to train the solution version backing the campaign, replace the
userId
parameter with itemId
and specify the item ID.
If you enabled metadata in recommendations for your campaign or recommender, you can specify the Items dataset metadata columns to include in the response. For a code sample, see Including item metadata with recommendations (Amazon SDKs). For information about enabling metadata, see Item metadata in recommendations.
If you recorded events for a user before they logged in (an anonymous user), you can get recommendations for this user by providing the sessionId
from those events
as if it is their userId
. For more information about recording events for anonymous users, see Recording events for
anonymous users.