Good day.
I am using AWS Personalize to generate recommendations and I am trying to upgrade to “aws-user-personalization-v2” from “aws-user-personalization”. The model has been trained with user-item-iteractions which includes a “TIME-OF-DAY” field witch takes values such as: “morning”, “afternoon”, “evening”.
The schema looks like this:
{
"type": "record",
"name": "Interactions",
"namespace": "com.amazonaws.personalize.schema",
"fields": [
{
"name": "USER_ID",
"type": "string",
"categorical": false
},
{
"name": "ITEM_ID",
"type": "string",
"categorical": false
},
{
"name": "TIMESTAMP",
"type": "long",
"categorical": false
},
{
"name": "EVENT_TYPE",
"type": "string",
"categorical": true
},
{
"name": "EVENT_VALUE",
"type": "float",
"categorical": false
},
{
"name": "TIME_OF_DAY",
"type": "string",
"categorical": true
}
],
"version": "1.0"
}
The Items schema conforms to the default schema as on AWS’s documentation. I query Personalize using boto3:
ACCOUNT = ...
REGION = ...
personalize_client = boto3.client("personalize-runtime")
...
def call_personalize_with_context(campaign_name: str, profileId: str, context_field: str, timeofday):
print(f"n== {context_field}:{timeofday} against {campaign_name} for {profileId} ===")
arn = f"arn:aws:personalize:{REGION}:{ACCOUNT}:campaign/{campaign_name}"
kwargs = {"campaignArn":arn, "userId":profileId}
if timeofday is not None:
kwargs["context"] = { context_field: timeofday }
response = personalize_client.get_recommendations(**kwargs)
for item in response['itemList']:
id = item['itemId']
print(f"{id}")
...
call_personalize_with_context("test_campaign", "john123", "TIME_OF_DAY", "morning")
call_personalize_with_context("test_campaign", "john123", "TIME_OF_DAY", "afternoon")
With the old recipe there is some variation in the result based on the context. However, if I train a model with the same data using the aws-user-personalization-v2 recipe it results in absolutely no variation.
Is there any differences in the way that I should use the new recipe with context? Should the schema be defined differently?
Any assistance would be appreciated.