Increasing recommendation relevance with contextual metadata
To increase recommendation relevance, include contextual metadata for a user, such as their device type or the time of day, when you get item recommendations or get a personalized ranking.
To use contextual metadata, the schema of the Item interactions dataset must have a metadata fields for the contextual data. For example, a DEVICE field (see Creating schema JSON files for your data).
For Domain dataset groups, the following recommender use cases can use contextual metadata:
-
Recommended for you (ECOMMERCE domain)
-
Top picks for you (VIDEO_ON_DEMAND domain)
For custom resources, recipes that use contextual metadata include the following:
For more information on contextual information, see the following Amazon Machine Learning Blog post:
Increasing the relevance of your Amazon Personalize recommendations by leveraging contextual information
You can get recommendations with contextual metadata with the Amazon Personalize console, Amazon Command Line Interface (Amazon CLI), or Amazon SDKs.
Getting recommendations using contextual metadata (Amazon Python SDK)
To increase recommendation relevance, include contextual metadata for a user, such as their device type or the time of day, when you get item recommendations or get a personalized ranking.
Use the following code to get a recommendation based on contextual metadata. For context
, for each key-value pair, provide the
metadata field as the key and the context data as the value. In the following sample code, the key is DEVICE
and the
value is mobile phone
. Replace these values and the Campaign ARN
and User ID
with your own.
If you created a recommender, replace campaignArn
with recommenderArn
.
A list of recommended items for the user displays.
import boto3 personalizeRt = boto3.client('personalize-runtime') response = personalizeRt.get_recommendations( campaignArn = '
Campaign ARN
', userId = 'User ID
', context = { 'DEVICE
': 'mobile phone
' } ) print("Recommended items") for item in response['itemList']: print (item['itemId'])