How to get recommendations from Domain dataset recommender with the SDK for Python (Boto3).

0

We use domain dataset group at Amazon Personalize. We finished to import data (interactions, users, items) and create an recommender (Recommended for you). We can get recommendations from the recommender with the Amazon Personalize console.

Then, we would like to get recommendations with the SDK for Python (Boto3). We sent request per following Developer Guide, however ParamValidationError occured. Getting recommendations with a recommender (AWS SDKs): https://docs.aws.amazon.com/personalize/latest/dg/domain-dsg-recommendations.html#get-domain-rec-sdk

How can we get recommendations from Domain dataset recommender with the SDK for Python (Boto3)?

We tried following pattens;

pattern1

Request

response = personalizeRt.get_recommendations(
    recommenderArn = 'Recommender ARN',
    userId = 'User ID',
    numResults = 10
)

Error

ParamValidationError: Parameter validation failed:
Missing required parameter in input: "campaignArn"
Unknown parameter in input: "recommenderArn", must be one of: campaignArn, itemId, userId, numResults, context, filterArn, filterValues

pattern2

Request

response = personalizeRt.get_recommendations(
    campaignArn = 'Recommender ARN',
    userId = 'User ID',
    numResults = 10
)

Error

InvalidInputException: An error occurred (InvalidInputException) when calling the GetRecommendations operation: The given campaign ARN is invalid: Recommender ARN
已提問 2 年前檢視次數 419 次
1 個回答
1
已接受的答案

Pattern 1 is the correct way to get recommendations from a domain recommender. Since the release of domain recommenders introduced an API change for the GetRecommendations API, ensure that you are using boto3 1.20.15 or newer. If you're using a Lambda function, keep in mind that dependencies like boto3 are updated less frequently in the base Lambda runtimes. Therefore, you may need to setup a requirements.txt to specify your min version and upload the boto3 package version you need with your function.

AWS
James_J
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南