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 02/20/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, if you have a campaign that is trained to give movie recommendations, you can use the following operations to give movie recommendations to users signed into your application or website. For an example, see Getting Started (AWS CLI).

The Amazon Personalize console details page for a campaign includes example code that you can use to get recommendations.

Recommendations

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

To get recommendations, you call the GetRecommendations API. You supply the Amazon Resource Name (ARN) of the required campaign, the user ID, and optionally, the item ID. GetRecommendations returns a list of recommended items for the user.

To get a recommendation

  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 if __name__ == "__main__": personalizert = boto3.client('personalize-runtime', region_name='us-west-2') response=personalizert.get_recommendations( campaignArn="Campaign ARN", userId='User ID', itemId='Item 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 PersonalizeRanking 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 using a recipe of type SEARCH_PERSONALIZATION. For more information, see Using Predefined Recipes.

To get a personalized ranking

  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 if __name__ == "__main__": personalizert = boto3.client('personalize-runtime', region_name='us-west-2') response=personalizert.personalize_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 most interest to the user.