Creating a campaign - Amazon Personalize

Creating a campaign

For real-time recommendations, after you complete Preparing and importing data and Creating a solution, you are ready to deploy your solution version to generate recommendations. You deploy a solution version by creating an Amazon Personalize campaign. If you are getting batch recommendations, you don't need to create a campaign. For more information see Getting batch recommendations.

A campaign is a deployed solution version (trained model) with provisioned dedicated transaction capacity for creating real-time recommendations for your application users. After you create a campaign, you use the GetRecommendations or GetPersonalizedRanking API operations to get recommendations.

You create a campaign with the Amazon Personalize console, AWS Command Line Interface (AWS CLI), or AWS SDKs.

Important

If you manually retrain your solution version or want to change your campaign settings, you must update your campaign. For more information see Updating a campaign.

Minimum provisioned transactions per second and auto-scaling

When you create an Amazon Personalize campaign, you specify a dedicated transaction capacity for creating real-time recommendations for your application users. A transaction is a single GetRecommendations or GetPersonalizedRanking call. Transactions per second (TPS) is the throughput and unit of billing for Amazon Personalize. The minimum provisioned TPS (minProvisionedTPS) specifies the baseline throughput provisioned by Amazon Personalize, and thus, the minimum billing charge.

If your TPS increases beyond minProvisionedTPS, Amazon Personalize auto-scales the provisioned capacity up and down, but never below minProvisionedTPS. There's a short time delay while the capacity is increased that might cause loss of transactions.

The actual TPS used is calculated as the average requests/second within a 5-minute window. You pay for maximum of the minimum provisioned TPS or the actual TPS. We recommend starting with a low minProvisionedTPS, track your usage using Amazon CloudWatch metrics, and then increase the minProvisionedTPS as necessary.

Creating a campaign (console)

After your solution version status is Active you are ready to deploy it with an Amazon Personalize campaign.

To create a campaign (console)

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

  2. Choose the dataset group with the solution version you want to deploy.

  3. In the navigation pane, choose Campaigns.

  4. On the Campaigns page, choose Create campaign.

  5. On the Create new campaign page, for Campaign details, provide the following information:

    • Campaign name: Enter the name of the campaign. The text you enter here appears on the Campaign dashboard and details page.

    • Solution: Choose the solution that you just created.

    • Solution version ID: Choose the ID of the solution version that you just created.

    • Minimum provisioned transactions per second: Set the minimum provisioned transactions per second that Amazon Personalize supports. For more information, see Minimum provisioned transactions per second and auto-scaling.

  6. If you used the User-Personalization recipe, in Campaign configuration optionally enter values for the Exploration weight and Exploration item age cut off. For more information see User-Personalization.

  7. Choose Create campaign.

  8. On the campaign details page, when the campaign status is Active, you can use the campaign to get recommendations and record impressions. For more information, see Getting recommendations.

    The campaign is ready when its status is ACTIVE. If you retrain your solution version or want to change your campaign settings, you must update your campaign. For more information see Updating a campaign.

Creating a campaign (AWS CLI)

After your solution version status is Active, you are ready to deploy it with an Amazon Personalize campaign. Use the following create-campaign AWS CLI command to create a campaign that deploys a solution version trained using the User-Personalization recipe. Give the campaign a name and specify the solution version ARN (Amazon Resource Name). Optionally change the minProvisionedTPS if your use case requires a higher provisioned capacity. The minimum value is 1.

The campaign-config parameters are specific to the recipe that you used to train the solution version (for more information about recipes see Step 1: Choosing a recipe). The example uses the following User-Personalization recipe specific itemExplorationConfig fields with their default values: explorationWeight and explorationItemAgeCutOff. If you omit the campaign-config parameter, the default values apply. For more information about the itemExplorationConfig fields, see the Properties and hyperparameters for the User-Personalization recipe.

aws personalize create-campaign \ --name campaign name \ --solution-version-arn solution version arn \ --min-provisioned-tps 1 \ --campaign-config "{\"itemExplorationConfig\":{\"explorationWeight\":\"0.3\",\"explorationItemAgeCutOff\":\"30\"}}"

The campaign is ready when its status is ACTIVE. To get the current status, call DescribeCampaign and check that the status field is ACTIVE.

If you retrain your solution version or want to change your campaign settings, you must update your campaign. For more information see Updating a campaign.

Amazon Personalize provides operations for managing campaigns such as ListCampaigns to list the campaigns you have created. You can delete a campaign by calling DeleteCampaign . If you delete a campaign, the solution versions that are part of the campaign are not deleted.

After you have created your campaign, use it to make recommendations. For more information, see Getting recommendations.

Creating a campaign (AWS SDKs)

After your solution version status is Active you are ready to deploy it with an Amazon Personalize campaign. Use the following code to create a campaign with the AWS SDK for Python (Boto3) or AWS SDK for Java 2.x.

The example code uses the following parameters (for a complete list of parameters, see CreateCampaign ):

  • A name for the campaign.

  • The solution version's ARN (Amazon Resource Name).

  • The Minimum provisioned TPS the campaign will support (the minimum value for this parameter is 1).

  • Optional campaign configuration parameters itemExplorationWeight and explorationItemAgeCutOff.

The campaign configuration parameters are specific to the recipe that you used to train the solution version (for more information about recipes see Step 1: Choosing a recipe). In this example, the itemExplorationWeight and explorationItemAgeCutOff parameters are specific to the User-Personalization recipe. The default itemExplorationWeight is 0.3 and the default explorationItemAgeCutOff is 30. If you leave out campaign configuration parameters, the default values apply.

SDK for Python (Boto3)
import boto3 personalize = boto3.client('personalize') response = personalize.create_campaign( name = 'campaign name', solutionVersionArn = 'solution version arn', minProvisionedTPS = 1, campaignConfig = {"itemExplorationConfig": {"explorationWeight": "0.3", "explorationItemAgeCutOff": "30"}} ) arn = response['campaignArn'] description = personalize.describe_campaign(campaignArn = arn)['campaign'] print('Name: ' + description['name']) print('ARN: ' + description['campaignArn']) print('Status: ' + description['status'])
SDK for Java 2.x
public static void createCampaign(PersonalizeClient personalizeClient, String campaignName, String solutionVersionArn, Integer minProvisionedTPS, String itemExplorationWeight, String explorationItemAgeCutOff) { //Optional code to instantiate a HashMap and add the explorationWeight and explorationItemAgeCutOff values. //Remove if you aren't using User-Personaliztion. Map<String,String> itemExploration = new HashMap<String,String>(); itemExploration.put("explorationWeight", itemExplorationWeight); itemExploration.put("explorationItemAgeCutOff", explorationItemAgeCutOff); try { // Build a User-Personalization recipe specific campaignConfig object with the itemExploration map. // CampaignConfig construction will vary by recipe. CampaignConfig campaignConfig = CampaignConfig.builder() .itemExplorationConfig(itemExploration) .build(); // build the createCampaignRequest CreateCampaignRequest createCampaignRequest = CreateCampaignRequest.builder() .name(campaignName) .solutionVersionArn(solutionVersionArn) .minProvisionedTPS(minProvisionedTPS) .campaignConfig(campaignConfig) // .build(); // create the campaign CreateCampaignResponse campaignResponse = personalizeClient.createCampaign(createCampaignRequest); String campaignArn = campaignResponse.campaignArn(); DescribeCampaignRequest campaignRequest = DescribeCampaignRequest.builder() .campaignArn(campaignArn) .build(); DescribeCampaignResponse campaignResponse = personalizeClient.describeCampaign(campaignRequest); Campaign newCampaign = campaignResponse.campaign(); System.out.println("The Campaign status is " + newCampaign.status()); } catch (PersonalizeException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }

The campaign is ready when its status is ACTIVE. To get the current status, call DescribeCampaign and check that the status field is ACTIVE.

If you manually retrain your solution version or want to change your campaign settings, you must update your campaign. For more information see Updating a campaign.

Amazon Personalize provides operations for managing campaigns such as ListCampaigns to list the campaigns you have created. You can delete a campaign by calling DeleteCampaign . If you delete a campaign, the solution versions that are part of the campaign are not deleted.

After you have created your campaign, use it to make recommendations. For more information, see Getting recommendations.