How to Get the recommendations using the AWS Python SDK?
Today lesson is how we will connect to AWS personalize campaign using the Python script and get the recommended items list. We are using Python (Latest: Python 3.8.2) and boto3 plugin to achieve this.
1. Install the Python
– Download the latest version of Python 3.8.2
2. Download and install boto3 library
$ pip install boto3
3. Get Recommendations from AWS Personalize
# importing the boto3 library import boto3 # connect to Personalize using boto3 client personalizeRt = boto3.client('personalize-runtime') # Get recommendations data by each campaign ARN response = personalizeRt.get_recommendations( campaignArn = 'Campaign ARN', userId = 'User ID') # Output recommendations data print("Recommended items") for item in response['itemList']: print (item['itemId'])
Note: You need to replace the “Campaign ARN” text with your actual Campaign ARN.
Thatβs it. I hope this will help. ?
Photo: https://www.brandeps.com