Creating a solution
You can create a custom solution with the Amazon Personalize console, AWS Command Line Interface (AWS CLI), or AWS SDKs. The following includes detailed steps to create a solution with the Amazon Personalize console and code examples that show how to create a solution with only the required fields.
Creating a solution (console)
Important
By default, all new solutions use automatic training. With automatic training, you incur training costs while
your solution is active. To avoid unnecessary costs, when you are finished you can update the solution to turn off automatic training. For information about training
costs, see Amazon Personalize pricing
To create a solution in the console, choose your dataset group and then specify a solution name, recipe, and optional training configuration.
To configure a solution (console)
-
Open the Amazon Personalize console at https://console.aws.amazon.com/personalize/home
, and sign in to your account. -
On the Dataset groups page, choose your dataset group.
-
On the Overview page, for Step 3, do one of the following:
-
If you created a Domain dataset group, choose Use custom resources, and choose Create solutions.
-
If you created a Custom dataset group, choose Create solutions.
-
-
For Solution name, specify a name for your solution.
-
For Solution type, choose the type of solution that you want to create. The type you choose determines what recipes are available.
-
Choose Item recommendation to get item recommendations for your users. For example, personalized movie recommendations.
-
Choose Action recommendation to get action recommendations for your users. For example, generate the next best action for a user, such as download your app.
-
Choose User segmentation to get user segments (groups of users) based on your item data.
-
-
For Recipe, choose a recipe (see Choosing a recipe).
-
For Tags, optionally add any tags. For more information about tagging Amazon Personalize resources, see Tagging Amazon Personalize resources.
-
Choose Next.
-
On the Training configuration page, customize the solution to meet your business requirements.
-
In Automatic training, choose whether the solution uses automatic training. If you use automatic training, you can change the
Automatic training frequency
. The default training frequency is every 7 days.We recommend using automatic training. It makes it easier for you to maintain recommendation relevance. Your training frequency depends on your business requirements, the recipe that you use, and how frequently you import data. For more information, see Configuring automatic training. For information about maintaining relevance, see Maintaining recommendation relevance.
-
In Hyperparameter configuration, configure any hyperparameter options based on your recipe and business needs. Different recipes use different hyperparameters. For the hyperparameters available to you, see the individual recipes in Choosing a recipe.
-
In Columns for training, if your recipe generates item recommendations or user segments, optionally choose the columns that Amazon Personalize considers when creating solution versions. For more information, see Configuring columns used when training.
-
In Additional configuration, if your Item interactions dataset has EVENT_TYPE or both EVENT_TYPE and EVENT_VALUE columns, optionally use the Event type and Event value threshold fields to choose the item interactions data that Amazon Personalize uses when training the model. For more information, see Choosing the item interaction data used for training.
-
If you use either the User-Personalization recipe or Personalized-Ranking recipe recipe, optionally specify an Objective and choose an Objective sensitivity to optimize your solution for an objective in addition to relevance. The objective sensitivity configures how Amazon Personalize balances recommending items based on your objective compared with relevance through interactions data. For more information, see Optimizing a solution for an additional objective.
-
-
Choose Next and review the solution details. You can't change your solution's configuration after you create it.
-
Choose Create solution. After you create a solution, Amazon Personalize starts creating your first solution version within an hour. When training starts, you can monitor it in the Solution versions section on the details page for you solution. Automatically created solution versions have a Training type of AUTOMATIC.
When the solution version is ACTIVE, you are ready to use it to get recommendations. How you use an active solution version depends on how you get recommendations:
For real-time recommendations, you deploy an ACTIVE solution version with an Amazon Personalize campaign. You use the campaign to get recommendations for your users. See Deploying an Amazon Personalize solution version with a campaign.
-
For batch recommendations, you specify an ACTIVE solution version when you create a batch inference job or batch segment job. See Getting batch item recommendations or Getting batch user segments.
Creating a solution (AWS CLI)
Important
By default, all new solutions use automatic training. With automatic training, you incur training costs while
your solution is active. To avoid unnecessary costs, when you are finished you can update the solution to turn off automatic training. For information about training
costs, see Amazon Personalize pricing
To create a solution with the AWS CLI, use the create-solution
command. This command uses the CreateSolution API operation. The following code shows you how to
create a solution that uses automatic training. It automatically creates a new solution version every five days.
To use the code, update it to give the solution a name, specify the Amazon Resource Name (ARN) of your dataset group, optionally change the training frequency, and specify the ARN of the recipe to use. For information about recipes, see Choosing a recipe.
aws personalize create-solution \ --name
solution name
\ --dataset-group-arndataset group ARN
\ --recipe-arnrecipe ARN
\ --perform-auto-training \ --solution-config "{\"autoTrainingConfig\": {\"schedulingExpression\": \"rate(5 days)\"}}"
-
We recommend that you use automatic training. It makes it easier for you to maintain and improve recommendation relevance. By default, all new solutions use automatic training. The default training frequency is every 7 days. Your training frequency depends on your business requirements, the recipe that you use, and how frequently you import data. For more information, see Configuring automatic training.
-
Depending on your recipe, you can modify the code to configure recipe specific properties and hyperparameters (see Hyperparameters and HPO), configure the columns used for training (see Configuring columns used when training (AWS CLI)), or filter the item interactions data used for training (see Choosing the item interaction data used for training).
-
If you use either the User-Personalization recipe or Personalized-Ranking recipe recipe, you can optimize your solution for an objective, in addition to relevance. For more information, see Optimizing a solution for an additional objective.
After you create the solution, record the solution ARN for future use. With automatic training, solution version creation starts within one after the solution is ACTIVE. If you manually create a solution version within the hour, the solution skips the first automatic training. After training starts, you can get the solution version's Amazon Resource Name (ARN) with the ListSolutionVersions API operation. To get its status, use the DescribeSolutionVersion API operation.
When the solution version is ACTIVE, you are ready to use it to get recommendations. How you use an active solution version depends on how you get recommendations:
For real-time recommendations, you deploy an ACTIVE solution version with an Amazon Personalize campaign. You use the campaign to get recommendations for your users. See Deploying an Amazon Personalize solution version with a campaign.
-
For batch recommendations, you specify an ACTIVE solution version when you create a batch inference job or batch segment job. See Getting batch item recommendations or Getting batch user segments.
Creating a solution (AWS SDKs)
Important
By default, all new solutions use automatic training. With automatic training, you incur training costs while
your solution is active. To avoid unnecessary costs, when you are finished you can update the solution to turn off automatic training. For information about training
costs, see Amazon Personalize pricing
To create a solution with AWS SDKs, use the CreateSolution API operation. The following code shows you how to create a solution that uses automatic training. It automatically creates a new solution version every five days.
To use the code, update it to give the solution a name, specify the Amazon Resource Name (ARN) of your dataset group, optionally change the training frequency, and specify the ARN of the recipe that you want to use. For information about recipes, see Choosing a recipe.
-
We recommend that you use automatic training. It makes it easier for you to maintain and improve recommendation relevance. By default, all new solutions use automatic training. The default training frequency is every 7 days. Your training frequency depends on your business requirements, the recipe that you use, and how frequently you import data. For more information, see Configuring automatic training.
-
Depending on your recipe, you can modify the code to configure recipe specific properties and hyperparameters (see Hyperparameters and HPO), configure the columns used for training (see Configuring columns used when training (AWS SDKs)), or filter the item interactions data used for training (see Choosing the item interaction data used for training).
-
If you use either the User-Personalization recipe or Personalized-Ranking recipe recipe, you can optimize your solution for an objective, in addition to relevance. For more information, see Optimizing a solution for an additional objective.
After you create the solution, record the solution ARN for future use. With automatic training, solution version creation starts within one after the solution is ACTIVE. If you manually create a solution version within the hour, the solution skips the first automatic training. After training starts, you can get the solution version's Amazon Resource Name (ARN) with the ListSolutionVersions API operation. To get its status, use the DescribeSolutionVersion API operation.
You can use the following Python code to wait for automatic training to start. The wait_for_training_to_start
method returns the ARN of the first solution version.
import time import boto3 def wait_for_training_to_start(new_solution_arn): max_time = time.time() + 3 * 60 * 60 # 3 hours while time.time() < max_time: list_solution_versions_response = personalize.list_solution_versions( solutionArn=new_solution_arn ) solution_versions = list_solution_versions_response.get('solutionVersions', []) if solution_versions: new_solution_version_arn = solution_versions[0]['solutionVersionArn'] print(f"Solution version ARN: {new_solution_version_arn}") return new_solution_version_arn else: print(f"Training hasn't started yet. Training will start within the next hour.") time.sleep(60) personalize = boto3.client('personalize') solution_arn = "
solution_arn
" solution_version_arn = wait_for_training_to_start(solution_arn)
When the solution version is ACTIVE, you are ready to use it to get recommendations. How you use an active solution version depends on how you get recommendations:
For real-time recommendations, you deploy an ACTIVE solution version with an Amazon Personalize campaign. You use the campaign to get recommendations for your users. See Deploying an Amazon Personalize solution version with a campaign.
-
For batch recommendations, you specify an ACTIVE solution version when you create a batch inference job or batch segment job. See Getting batch item recommendations or Getting batch user segments.