How to use the templated ML solution for transactional churn?

In this article, we demonstrate how to use the templated machine-learning solution of the AI & Analytics Engine to predict the possibility of customer churn for a transaction-based business.

Watch the walkthrough video:

HubSpot Video

Customer churn is a major concern for many businesses, as it directly impacts revenue and business strategy. To identify which customers are likely to churn, a comprehensive solution is required that involves complex and labor-intensive data processing steps, selecting the relevant factors that affect churn and applying the suitable machine learning algorithm. However, this is not a trivial task and it varies depending on the nature of the business. The AI & Analytics Engine offers you an effective solution to this problem. Users just need to enter some quantitative information about their business nature and objectives, and the entire process will be automated, enabling the user to predict customer churn with speed and accuracy.

In this article, we will explore the customer churn prediction template specifically for transactional businesses. This refers to businesses with customers that make transactions or individual purchases. We will demonstrate how to use this template using a banking use case.

Note: If you own subscription-based businesses (e.g.: telecom, online video streaming, etc.), check out this article instead.

Use case: Predicting customer churn for banking service

Suppose you are a bank employee who wants to utilize your customer data to initiate a successful customer retention campaign. Your aim is to identify customers who are prone to leave your service in the near future, and develop effective marketing strategies to retain them. To accomplish this, you understand that you need a model that can help predict customer churn based on your available data. Once you have a trained model, you can use it to predict which of your current active customers are likely to churn, and act accordingly in order to retain them. This can result in significant cost savings, as retaining existing customers is usually much cheaper than acquiring new ones.

The input data required for this predictive modeling (and at your disposal) consists of the following tables:

  1. Customer transactions: a table that records the details of customer transactions, with three key attributes that will be used later: customer ID (who made the transaction), transaction date (when) and transaction amount.

  2. Customer information: this table contains customer demographic data.

The figures below show a sample of these two tables:

Preview of the transactions tablePreview of the transactions table. Three key attributes are "account_id", "date" and "amount".

Preview of the customer-information tablePreview of the customer-information table

Note: The transactions and customer-information data used in this article are obtained from the Czech bank dataset, available here.

Creating a Customer Churn Prediction app with the template

In this section, we will follow some simple steps and provide the required information to create an application that uses machine-learning models to predict customer churn. You will observe how this templated solution shortens the time between feeding raw data to getting insightful predictions.

To access the app builder, on the project overview page, select the “Use template” option and then choose “Customer Churn”.

Template option

1. Choose “Use template”

Customer churn template

2. Then, choose “Customer Churn” template

Step 1: Select a template that matches your business type

Selecting a template that matches your business typeChoose the second option for transactional businesses

Step 2: Import the transaction data and the optional customer-information data

Select the appropriate columns in the transaction dataset

Select the appropriate columns in the transaction dataset

Select the identifier column in the customer-information dataset

Select the identifier column in the customer-information dataset

Step 3: Define churn

Appropriately define churn based on business behavior and goalsDefine churn based on business behavior and goals


For more information about the churn definition, read this article.

Step 4: Determine the time frames in the past that influence the probability of churn

three time-frames are provided

By default, three time-frames are provided. You can customize them or add more

Select appropriate attributes from the customer-information dataset

Select appropriate attributes from the customer-information dataset

Note: The Engine will calculate various statistics for the transaction amount based on the specified time frames. These statistics enable the machine-learning model to detect customer behavior patterns as they reflect in their past transactions and apply that knowledge to predict the future. 

  • For more information about these statistics, read this article.
  • For a better understanding of how the Engine processes the data, read this article.

Final step: Configure model training

Let the Engine find the top 3 algorithms, or select them manuallyLet the Engine find the top 3 algorithms, or select them manually

The app-building process will start as soon as we complete this step, and the resulting app will allow us to make predictions and explore the model insights.

Inspecting the model performance

Once the app building process is complete, we get a trained model. On the upper right side, there is a short overview of the best trained model, which shows the prediction quality of that model. 

The recommended model and its prediction qualityThe recommended model and its prediction quality

For more detailed information about the model performance, we can click on the model name, and navigate to the “Insights” tab. This tab displays evaluation results over a test dataset (data previously unseen by the model and not used for training). These results should be close to the actual model performance once it is deployed. 

Detailed metrics to measure model performanceDetailed metrics to measure model performance

Apart from getting insights about the accuracy of the model predictions, these are some of the questions a user might want to know:

  • What are the most important behavioral predictors for customer churn?

  • Is an increase in the average time between consecutive transactions?

  • Is it a series of low valued transactions relative to older, higher valued transactions?

    To answer these questions, the evaluation supplies us the feature importance of the trained model:

The importance of each contributing factor in percentageThe importance of each contributing factor in percentage

For more information about the importance of each feature in the trained model, read this article.

Lastly, when we examine a prediction for a specific customer, we might see that his likelihood of churn in the observation period is 70%. We would like to know, for that customer, what are the factors increasing/decreasing his/hers likelihood of churn. We can do so by inspecting the prediction explanations. 

For more information about prediction explanations, read this article.

Making predictions

To initiate a prediction, click on the “Make prediction” button on the app overview page. You have the option to select either a “one-time prediction” or “periodically scheduled predictions”, which generates predictions at regular intervals. In both options, you’d need to provide the data sources for transactions and customer-information datasets, as when creating the template.

Provide the necessary inputs for predictionProvide the necessary inputs for prediction

For the scheduled periodic prediction option, you also need to select the frequency that the Engine will perform the prediction.

Specify the schedule in the periodic prediction optionSpecify the schedule in the periodic prediction option

Once the prediction is done, you can preview a sample of it, download it to your device, or export it to other sources for related tasks.

image-20230629-211838A preview of the predicted churn probability (in the final column) for each active customer

For more information about the supported options for prediction, read this article.


In this article, we demonstrated how the AI & Analytics Engine can assist you in predicting customer churn for a transactional business with an efficient and effective solution. In order to create a customer churn prediction model, you only need to upload your raw datasets and define a few configuration features, which we have illustrated using a banking scenario. This enables you to understand your customers' behaviors, and develop the appropriate retention strategies to prevent them from churning.