Automated Deployment - Predictive Segmentation Using Amazon Pinpoint and Amazon SageMaker

Automated Deployment

Before you launch the automated deployment, please review the considerations discussed in this guide. Follow the step-by-step instructions in this section to configure and deploy Predictive Segmentation Using Amazon Pinpoint and Amazon SageMaker into your account.

Time to deploy: Approximately 10 minutes


Before you deploy this solution, you must have a configured Amazon Pinpoint project in the same AWS Region where you plan to deploy the solution. You will need to enter the project ID in the Application ID AWS CloudFormation template parameter. For more information, see Amazon Pinpoint.

What We'll Cover

The procedure for deploying this architecture on AWS consists of the following steps. For detailed instructions, follow the links for each step.

Step 1. Launch the Stack

  • Launch the AWS CloudFormation template into your AWS account.

  • Enter values for the required parameters: Stack Name, Application ID.

  • Review the other template parameters, and adjust if necessary.

Step 2. Run the Notebook

  • Run the Jupyter Notebook to train the ML model.

Step 3. Execute the State Machine

  • Execute the AWS Step Functions state machine.

Step 4. Verify the Segment Exists and is Receiving Records

  • Verify that the solution created the Amazon Pinpoint segment, and that the churn segment shows records.

Step 1. Launch the Stack

This automated AWS CloudFormation template deploys Predictive Segmentation Using Amazon Pinpoint and Amazon SageMaker in the AWS Cloud. Please make sure that you have an existing Amazon Pinpoint project before launching the stack.


You are responsible for the cost of the AWS services used while running this solution. See the Cost section for more details. For full details, see the pricing webpage for each AWS service you will be using in this solution.

  1. Sign in to the AWS Management Console and click the button below to launch the predictive-segmentation-using-amazon-pinpoint-and-amazon-sagemaker AWS CloudFormation template.

                                Predictive Segmentation Using Amazon Pinpoint and Amazon SageMaker launch button

    You can also download the template as a starting point for your own implementation.

  2. The template is launched in the US East (N. Virginia) Region by default. To launch this solution in a different AWS Region, use the region selector in the console navigation bar.


    This solution uses Amazon Pinpoint, which is currently available in specific AWS Regions only. Therefore, you must launch this solution in an AWS Region where Amazon Pinpoint is available. For the most current service availability by region, see the AWS service offerings by region.

  3. On the Create stack page, verify that the correct template URL shows in the Amazon S3 URL text box and choose Next.

  4. On the Specify stack details page, assign a name to your solution stack.

  5. Under Parameters, review the parameters for the template, and modify them as necessary.This solution uses the following default values.

    Parameter Default Description
    Application ID <Requires input>

    The Amazon Pinpoint project ID that contains the endpoints to be exported and where the churn segment will be created

    SageMaker Model Name deployed-xboost-customer-churn The name of the model and training job
    SageMaker Model Training Instance Type ml.m4.xlarge The SageMaker instance type used for model training
    SageMaker Model Transform Instance Type ml.m5.large The SageMaker instance type used for batch transform requests
    Churn Prediction Threshold .40 The scoring threshold that will determine whether a customer is added to the churn Amazon Pinpoint segment
  6. Choose Next.

  7. On the Configure stack options page, choose Next.

  8. On the Review page, review and confirm the settings. Be sure to check the box acknowledging that the template will create AWS Identity and Access Management (IAM) resources.

  9. Choose Create stack to deploy the stack.

    You can view the status of the stack in the AWS CloudFormation console in the Status column. You should see a status of CREATE_COMPLETE in approximately 10 minutes.


In addition to the primary AWS Lambda functions, this solution includes the CustomResourceHelper Lambda function, which runs only during initial configuration or when resources are updated or deleted.

When running this solution, the CustomResourceHelper Lambda function is inactive. However, do not delete the function as it is necessary to manage associated resources.

Step 2. Run the Notebook

  1. Navigate to the Amazon SageMaker console.

  2. In the navigation pane, select Notebook instances.

  3. Select PredictiveChurnNotebookInstance.

    The notebook instance should already be running.

  4. Select Open Jupyter.

  5. In the Jupyter notebook interface, open the xboost_customer_churn.ipynb file.

  6. In the Cell dropdown menu, select Run All to run the file.


After you run the notebook, you can terminate the Notebook instance to reduce costs.

Step 3. Execute the State Machine

  1. Navigate to the AWS Step Functions console.

  2. In the navigation pane, select State machines.

  3. Select the the solution’s state machine. The name starts with DailyChurnListStateMachine.

  4. Select Start execution.

    Wait for the state machine to finish executing. It can take up to 10 minutes to complete all of the steps.

Step 4. Verify the Segment Exists and is Receiving Records

  1. Navigate to the Amazon Pinpoint console.

  2. In the All Projects list, select the applicable project.

  3. In the navigation pane, select Segments.

  4. Select the Predicted to Churn segment.

  5. Under Number of Records, verify there are entries.