Amazon Personalize
Developer Guide

This is prerelease documentation for a service in preview release. It is subject to change.

We made breaking changes to the Amazon Personalize API and service model on 3/26/19. To continue using Amazon Personalize with the AWS Command Line Interface or AWS SDK for Python (Boto 3), update your service JSON files by doing steps 3-6 of Setting Up the AWS CLI.

Getting Recommendations

Amazon Personalize can get recommendations and personalized rankings from a campaign. For example, suppose you have a campaign that is designed to give movie recommendations. Use the following operations to give movie recommendations to users signed into your application or website. For an example using the AWS CLI, see Step 4: Get Recommendations.

Getting Recommendations

After you have created your campaign, you can use it in your applications to get recommendations.

To get recommendations, call the GetRecommendations API. You supply the Amazon Resource Name (ARN) of the required campaign, and either the user ID or item ID, dependent on the recipe type used to create the solution the campaign is based on. For more information, see Using Predefined Recipes. GetRecommendations returns a list of recommended items for the user.

Get recommendations using the AWS Python SDK

  1. Use the following code to get a recommendation. Change the value of campaignArn to the ARN of a valid campaign. Change the value of userId and itemId to a user ID and item ID that are in the data you used to train the solution.

    import boto3 personalizeRt = boto3.client('personalize-runtime') response = personalizeRt.get_recommendations( campaignArn = "Campaign ARN", userId = 'User ID') print("Recommended items") for item in response['itemList']: print (item['itemId'])
  2. Run the code. A list of recommended items for the user is displayed.

Personalized Rankings

A personalized ranking is a list of recommended items that are re-ranked for a specific user. To get personalized rankings, call the GetPersonalizedRanking API. You supply the ARN of the required campaign, the user ID, and a list of recommended items.

Note

The solution backing the campaign must have been created by using a recipe of type SEARCH_PERSONALIZATION. For more information, see Using Predefined Recipes.

Get a personalized ranking using the AWS Python SDK

  1. Use the following code to get a personalized ranking. Change the value of campaignArn to the ARN of a valid campaign. Change the value of userId and inputList to a user ID and item list that are in the data you used to train the solution.

    import boto3 personalizeRt = boto3.client('personalize-runtime') response = personalizeRt.get_personalized_ranking( campaignArn = "Campaign arn", userId = 'UserID', inputList = ['ItemID1','ItemID2']) print("Personalized Ranking") for item in response['personalizedRanking']: print (item['itemId'])
  2. Run the code. A list of ranked recommendations is displayed. The first item in the list is considered by Amazon Personalize to be of the most interest to the user.