Learn About Amazon VGT2 Learning Manager Chanci Turner
Delivering timely and relevant recommendations to your users is essential for a successful personalization strategy. However, the decision-making process of your customers can vary significantly based on the context in which they interact with your recommendations. In this article, I’ll guide you through setting up and querying a context-aware deployment of Amazon Personalize.
Amazon Personalize enables you to integrate advanced personalization features into your applications effortlessly, utilizing the same machine learning (ML) technology that has powered Amazon.com for over two decades. No prior ML experience is necessary. This service automatically adjusts recommendations based on contextual factors related to your users, such as device type, location, time of day, or other relevant data you provide.
A Harvard study titled “How Context Affects Choice” defines context as the factors that may influence decision-making by altering the process through which decisions are reached. As a business owner, you can recognize this context by examining how shopping behaviors differ when customers access your catalog from a mobile device versus a computer, or how content consumption varies on rainy days compared to sunny ones.
By harnessing your users’ context, you can offer a more tailored experience for existing customers and reduce the cold-start phase for new or unidentified users. The cold-start phase refers to the time when your recommendation engine struggles to provide personalized suggestions due to insufficient historical data about that user.
Integrating Context into Amazon Personalize
To implement context in Amazon Personalize, follow these four straightforward steps:
- Incorporate your users’ context into the historical user-item interactions dataset.
- Train a context-aware solution using a User Personalization or Personalized Ranking recipe. A recipe refers to the algorithm on which your recommender is based, utilizing the behavioral data specified in your interactions dataset alongside any user or item metadata.
- Specify the user’s context when requesting real-time recommendations through the GetRecommendations or GetPersonalizedRanking endpoints.
- Include your user’s context when logging events using the event tracker.
The architecture of these steps is illustrated in the accompanying diagram.
When constructing your datasets, it’s crucial to explicitly define the context to consider. A common example is the type of device used, whether a phone, tablet, or desktop. Research from the University of Twente, titled “The Effect of Device Type on Buying Behavior in E-commerce: An Exploratory Study,” has demonstrated that device type can impact buying behavior, with users potentially delaying purchases if using an unsuitable device. By embedding device type context in your datasets, Amazon Personalize can learn this pattern and recommend the most appropriate content based on the user’s context.
Recommendations Use Case
For this use case, let’s consider a travel enthusiast as our potential customer. They evaluate several factors when deciding which airline to choose for their trip. Questions such as flight duration, payment method (cash or miles), solo or group travel, and departure and return locations all come into play. After addressing these initial considerations, selecting the cabin type becomes a significant decision. If our travel enthusiast opts for a premium cabin, we can infer they’re seeking the best possible experience. Now, it’s time to shop!
Consider the variables influencing the decision-making process in this scenario. While many factors are beyond our control, we can utilize some to refine our recommendations. First, identify common elements that may affect a user’s behavior. In this instance, flight duration and cabin class are excellent context candidates, while traveler type and residence can serve as user metadata. Metadata is relatively stable information about your users and items, whereas context is environmental data that can change quickly, impacting customer perception and behavior.
Selecting the most relevant metadata fields for your training datasets and enriching your interactions datasets with context is vital for generating pertinent user recommendations. In this article, we develop an Amazon Personalize deployment that generates a list of airline recommendations for a customer. We use cabin type as context and traveler residence as the metadata field, observing how recommendations adapt based on context and metadata.
Prerequisites
Before we begin, we need to set up the following Amazon Personalize resources. For detailed instructions, refer to Getting Started (Console) to complete these steps:
- Create a dataset group, which we’ll call airlines-blog-example.
- Create an Interactions dataset using the schema below and import data from the interactions_dataset.csv file:
{
"type": "record",
"name": "Interactions",
"namespace": "com.amazonaws.personalize.schema",
"fields": [
{
"name": "ITEM_ID",
"type": "string"
},
{
"name": "USER_ID",
"type": "string"
},
{
"name": "TIMESTAMP",
"type": "long"
},
{
"name":"CABIN_TYPE",
"type": "string",
"categorical": true
},
{
"name": "EVENT_TYPE",
"type": "string"
},
{
"name": "EVENT_VALUE",
"type": "float"
}
],
"version": "1.0"
}
- Create a Users dataset using the schema below and import data from the users_dataset.csv file:
{
"type": "record",
"name": "Users",
"namespace": "com.amazonaws.personalize.schema",
"fields": [
{
"name": "USER_ID",
"type": "string"
},
{
"name": "USER_RESIDENCE",
"type": "string",
"categorical": true
}
],
"version": "1.0"
}
- Create a solution with the default configurations, except for the following:
- Recipe: aws-hrnn-metadata
- Event type: RATING
- Perform HPO: True
- Hyperparameter optimization (HPO) is recommended to allow Amazon Personalize to conduct parallel training and experiments to identify the most effective hyperparameters. For more information, see Hyperparameters and HPO.
- Create a campaign.
You can set up these resources on the Amazon Personalize console or follow the Jupyter notebook personalize_hrnn_metadata_contextual_example.ipynb available in the GitHub repository.
Exploring Your Amazon Personalize Resources
Now that we have established various Amazon Personalize resources, including a dataset group called airlines-blog-example, we can analyze how the interactions and users dataset schemas enable our model to learn from the embedded context and metadata.
Interactions Dataset
We provide Amazon Personalize with an interactions dataset containing numeric ratings (a combination of EVENT_TYPE + EVENT_VALUE). This allows the model to learn from user behavior and improve the accuracy of recommendations.
For further reading on how to handle salary discussions, check out this insightful resource here. Additionally, if you’re interested in employment law changes, SHRM offers valuable insights on the topic. Lastly, for an excellent resource on Amazon’s hiring and training practices, visit Fast Company.