Optimizing a solution for an additional objective - Amazon Personalize

Optimizing a solution for an additional objective

The ability to optimize a solution is in preview release and is subject to change at any time. Changes will affect only solutions that use this feature and will not result in data loss.

The primary objective of Amazon Personalize is to predict the most relevant items for your users based on historical and real-time interactions data. These are the items your users will most likely interact with (for example, the items they will most likely click). If you have an additional objective, such as maximizing streaming minutes or increasing revenue, you can create a solution that generates recommendations based on both relevance and your objective.

After you create an Interactions dataset and an Items dataset with a column of numerical metadata, you can create a solution that is optimized for an additional objective based on your item metadata. To optimize a solution for an additional objective, create a new solution with the User-Personalization recipe or Personalized-Ranking recipe and choose the numerical metadata column in your Items dataset that is related to your objective. For example, you might choose a VIDEO_LENGTH column to maximize streaming minutes or a PRICE column to maximize revenue.

When generating recommendations, Amazon Personalize gives more importance to items with higher values for this column of data. You can choose only one column for your objective and the metadata must be numerical.

To optimize a solution for an objective, you can use the Amazon Personalize console, AWS Command Line Interface (AWS CLI), or AWS SDKs.

Balancing objective emphasis and relevance

There can be a trade-off when recommending items based more on your objective than relevance. For example, if you want to increase revenue through recommendations, recommendations for only expensive items might make items less relevant for your users and decrease user engagement and conversion.

To configure the balance between relevance and your objective, choose one of the following objective sensitivity levels when you create the solution:

  • Off: Amazon Personalize uses primarily interactions data to predict the most relevant items for your user.

  • Low: Amazon Personalize places less emphasis on your objective. Relevance through interactions data is more important.

  • Medium: Amazon Personalize places equal emphasis on your objective and relevance through interactions data.

  • High: Amazon Personalize places more emphasis on your objective. Relevance through interactions data is less important.

Measuring optimization performance

When you create a solution version (train a model) for a solution with an optimization objective, Amazon Personalize generates an average_rewards_at_k metric. The score for average_rewards_at_k tells you how well the solution version performs in achieving your objective. Amazon Personalize calculates this metric by dividing the total rewards generated by interactions (for example, total revenue from clicks) by the total possible rewards from recommendations. The higher the score, the more gains on average per user you can expect from recommendations.

For example, if your objective is to maximize revenue, Amazon Personalize divides the total revenue generated by interactions (for example, revenue from all of the items that users clicked), by the total possible revenue from recommendations. The resulting average_rewards_at_k score tells you how much revenue on average you can expect to gain per user from recommendations.

For more information about generating metrics, see Step 4: Evaluating a solution version with metrics.

Optimizing a solution (console)

To optimize a solution for an additional objective with the Amazon Personalize console, create a new solution and choose the column of numerical item metadata that is related to your objective.

To optimize a solution for an additional objective (console)

  1. Open the Amazon Personalize console at https://console.aws.amazon.com/personalize/home and sign in to your account.

  2. Choose the dataset group that you want to use for training.

  3. In the Create solutions section of the dashboard, choose the Start button. If you have already created a solution, choose the Create solution button.

  4. For Solution name, specify a name for the solution.

  5. For Recipe, choose either User-Personalization recipe or Personalized-Ranking recipe.

  6. In Solution configuration, if your data has EVENT_TYPE or EVENT_VALUE_THRESHOLD columns, use the following fields to choose the interactions data that Amazon Personalize uses when training the model.

    • Event type: If your data has multiple event types in an EVENT_TYPE column and you want to train with just a single type of event, optionally enter an event type, such as click. Amazon Personalize will use only events with this type when training a model. You can enter only one type. If you don't provide an event type, Amazon Personalize trains the model with all interactions data regardless of type.

    • Event value threshold: If your Interactions dataset has an EVENT_VALUE_THRESHOLD column and you want to train events based on value, optionally enter a value. Amazon Personalize will use only events with a value greater than or equal to this value to train the model. If you don't provide a value, Amazon Personalize trains the model with all interactions data regardless of value.

    For more information see Choosing the interactions data used for training.

  7. For Objective, choose the numerical column from the Items dataset that is related to your objective. You can choose only a numerical metadata column.

  8. For Objective sensitivity, choose the level of emphasis Amazon Personalize places on the additional objective when generating recommendations. The objective sensitivity configures how Amazon Personalize balances recommending items based on your objective versus relevance through interactions data. For more information, see Balancing objective emphasis and relevance.

  9. Configure any hyperparameter options based on your recipe and business needs. Different recipes use different hyperparameters. For available hyperparameters, see the documentation for individual recipes in Step 1: Choosing a recipe.

  10. Choose Next.

  11. On the Create solution version page, create a new solution version for the solution. For details, see Creating a solution version (console). Once you create a solution version, you can view the optimization performance in the solution version metrics. See Measuring optimization performance.

Optimizing a solution (AWS CLI)

You can optimize for an objective only with the User-Personalization or Personalized-Ranking recipe. To optimize a solution for an additional objective using the AWS CLI, create a new solution and specify your objective details using the optimizationObjective key in the solutionConfig object. The optimizationObjective has the following fields:

  • itemAttribute: Specify the name of the numerical metadata column from the Items dataset that relates to your objective.

  • objectiveSensitivity: Specify the level of emphasis that the solution places on your objective when generating recommendations. The objective sensitivity level configures how Amazon Personalize balances recommending items based on your objective versus relevance through interactions data. The objectiveSensitivity can be OFF, LOW, MEDIUM or HIGH. For more information, see Balancing objective emphasis and relevance.

The following is an example of the create-solution AWS CLI command. Replace the solution name, dataset group arn, and recipe arn values with your own.

For optimizationObjective, replace COLUMN_NAME with the numerical metadata column name from the Items dataset that is related to your objective. For objectiveSensitivity, specify OFF, LOW, MEDIUM, or HIGH.

aws personalize create-solution \ --name solution name \ --dataset-group-arn dataset group arn \ --recipe-arn recipe arn \ --solution-config "{\"optimizationObjective\":{\"itemAttribute\":\"COLUMN_NAME\",\"objectiveSensitivity\":\"MEDIUM\"}}"

When your solution is ready, create a new solution version (for an example command see Configuring a solution (AWS CLI)). Once you create a solution version, you can view the optimization performance with the solution version metrics. See Measuring optimization performance.

Optimizing a solution (AWS SDKs)

You can optimize for an objective only with the User-Personalization or Personalized-Ranking recipe.

To optimize a solution for an additional objective using the AWS SDKs, create a new solution and specify your objective details using the optimizationObjective key in the solutionConfig object for the solution. The optimizationObjective has the following fields:

  • itemAttribute: Specify the name of the numerical metadata column from the dataset group's Items dataset that relates to your objective.

  • objectiveSensitivity: Specify the level of emphasis that the solution places on your objective when generating recommendations. The objective sensitivity level configures how Amazon Personalize balances recommending items based on your objective versus relevance through interactions data. The objectiveSensitivity can be OFF, LOW, MEDIUM or HIGH. For more information, see Balancing objective emphasis and relevance.

Use the following code to create a solution with an additional objective with the AWS SDK for Python (Boto3) or the AWS SDK for Java 2.x.

When your solution is ready, create a new solution version (for example code see Creating a solution version (AWS SDKs)). Once you create a solution version, you can view the optimization performance with the solution version metrics. See Measuring optimization performance.

SDK for Python (Boto3)

To create a solution that is optimized for an additional objective, use the following create_solution method. Replace the solution name, dataset group arn, and recipe arn values with your own.

For optimizationObjective, replace COLUMN_NAME with the numerical metadata column name from the Items dataset that is related to your objective. For objectiveSensitivity, specify OFF, LOW, MEDIUM, or HIGH.

import boto3 personalize = boto3.client('personalize') create_solution_response = personalize.create_solution( name= 'solution name', recipeArn= 'recipe arn', datasetGroupArn = 'dataset group arn', solutionConfig = { "optimizationObjective": { "itemAttribute": "COLUMN_NAME", "objectiveSensitivity": "MEDIUM" } } ) solution_arn = create_solution_response['solutionArn'] print('solution_arn: ', solution_arn)
SDK for Java 2.x

To create a solution that is optimized for an additional objective, use the following createPersonalizeSolution method and pass the following as parameters: an Amazon Personalize service client, the dataset group's Amazon Resource Name (ARN), a solution name, the recipe ARN, the item attribute, and the objective sensitivity level.

public static String createPersonalizeSolution(PersonalizeClient personalizeClient, String datasetGroupArn, String solutionName, String recipeArn, String itemAttribute, String objectiveSensitivity) { try { OptimizationObjective optimizationObjective = OptimizationObjective.builder() .itemAttribute(itemAttribute) .objectiveSensitivity(objectiveSensitivity) .build(); SolutionConfig solutionConfig = SolutionConfig.builder() .optimizationObjective(optimizationObjective) .build(); CreateSolutionRequest solutionRequest = CreateSolutionRequest.builder() .name(solutionName) .datasetGroupArn(datasetGroupArn) .recipeArn(recipeArn) .solutionConfig(solutionConfig) .build(); CreateSolutionResponse solutionResponse = personalizeClient.createSolution(solutionRequest); return solutionResponse.solutionArn(); } catch (PersonalizeException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return "";