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
gefragt vor 2 Jahren419 Aufrufe
1 Antwort
1
Akzeptierte Antwort

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
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen