This article demonstrates how to use the Customer Lifetime Value (CLV) Prediction Machine Learning Solution Template for a transaction-based business.
Customer lifetime value (CLV) is an important metric for businesses as it provides them the opportunity to maximise the value of the customer relationship. Correctly identifying the CLV of a customer allows businesses to provide better customer experience, which improves customer loyalty as well as the product/service quality the business offers.
To predict CLV, a comprehensive solution is required that involves complex and labor-intensive data processing steps, selecting the relevant factors that affect CLV and applying the suitable machine learning algorithm.
This is not a trivial task and it varies depending on the nature of the business. The AI & Analytics Engine offers an effective solution to this problem with the Customer Lifetime Value Prediction ML Solution Template.
You just need to enter some quantitative information about your business nature and objectives, and the entire process will be automated, enabling you to predict CLV with speed and accuracy.
This article will explore the Customer Lifetime Value template for a transactional business. This refers to businesses with customers that make transactions or individual purchases.
🎓To learn more about the other templates the Engine offers, read What templates are supported on the Engine
Use case
Suppose you’re a bank employee who wants to use your customer data to identify the CLV of customers of your business, so you can generate a monthly report of the highest value customers.
To accomplish this, you use the Engine’s Customer Lifetime Value Prediction template to to generate monthly CLV predictions of your customers.
Data
The input data required for the template consists of the following datasets:
Customer transaction dataset
A required dataset that records the details of customer transactions, with three key attributes that will be used:
-
account_id (who made the transaction)
-
date (when the customer made the transaction)
-
amount
In this specific example each transaction represents a record of a spending or a refund. There are other columns such as trans_id, type, operation, etc. which won’t be used here.
Preview of the customer transactions dataset
Customer transaction dataset
An optional dataset that contains customer biographic/demographic profile data: Eg. district ID, sex and date of birth, etc.
Preview of the customer information dataset
The transactions and customer information data used in this article are obtained from the Czech bank dataset which is publicly available.
Creating a Customer Lifetime Value Prediction app
In this section, you can follow some simple steps and provide the required information to create an application that uses machine-learning models to predict CLV.
To access the app builder, on the Project Home page, select Customer Lifetime Value under Machine Learning Solution Templates.
Select Customer Lifetime Value from the Project home page
Then create the application by selecting the Use this template and naming the application. This will take you to the App builder pipeline.
Select Use this template to create the application
Step 1: Define business requirements
You need to define the business requirements including defining CLV and the prediction frequency. This step requires an understanding of what CLV means to your business.
For this example, define CLV as: The total transaction amount for the customer in next 180 days.
Select a prediction frequency of 1 month.
Appropriately define CLV and prediction frequency based on business goals
💡Generally, “customer lifetime value” is calculated through their entire lifetime, i.e., until they churn/end their relationship with the business.
In Machine Learning, prediction of CLV refers to predicting how much/how many items a customer will buy in a specific finite future time period. For example: Over the next year.
It is not possible to have training data such that we can build a model to predict for “until the end of customer’s lifetime with the business”. Moreover, increasing the time window will make the prediction more and more unreliable.
Step 2: Import the transaction data and the optional customer-information data
Review the data requirements to build the models. Based on the parameters provided when defining the business requirements, your transaction history data required must span at least 390 days.
The data you need is:
-
Transaction data (required data)
-
Customer info (optional data)
Review data requirements
Review the requirements for the transactions dataset. The transactions should only be spending or refund. Then add the transactions dataset and select the appropriate columns.
Review the requirements for the customer information dataset. Then add the customer information dataset and select the appropriate columns.
Step 3: Determine the time frames in the past that influence the customer lifetime value
In this step, it is crucial to identify the time frames in which customer transaction patterns may indicate their CLV. Initially, three time frames have been pre-selected for you, as depicted in the figure below. These can be altered or supplemented with any additional time frames that meet your requirements.
Furthermore, the potential influence of demographic information should be taken into account. You can choose any demographic factors that you believe might impact the customer's lifetime value.
By default, three time-frames are provided. You can customize them or add more
Select appropriate attributes from the customer information dataset
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.
Step 5: Configure model training
The final stage involves selecting the configuration for your model's training. You have the option to allow the Engine to automatically identify the best models according to your specified criteria, or you can choose to manually select the algorithms.
For this example, select the top 3 algorithms with no additional filters.
Automatically train top algorithms based on given criteria
The app-building process will start as soon as you complete this step and click Start building, and the resulting app will allow us to make predictions and explore the model insights.
You will be directed to the App summary page with the label Processing. You can see the progress of the app in each panel.
App summary page once the app is ready
Analysing Customer Lifetime Value in historical data
Once the training dataset is complete, you can click View analysis under Data preparation in the App Summary page to see the charts analysing CLV in historical data.
Analysis charts of historical CLV
Inspecting the ML Model
Once the app building process is complete, the models begin training. When the training is complete, on the right side of the App Summary page there is a short overview of the best trained model, which shows the prediction quality of that model.
The recommended model and its prediction quality
🎓For more information about how a model is evaluated in the Customer Lifetime Value Prediction template, read How are models evaluated in ML Solution Templates
Performance
For more detailed information about the model performance, you can click on the model name, and navigate to the Insights tab, which will display the Performance page, which provides insights on the accuracy of the models prediction.
Included is Prediction error breakdown for different bins in the predicted CLV value, multiple evaluation metrics and charts such as predicted vs actual, residual vs predicted CLV and residual distribution.
Performance page under Insights tab
🎓For more information about evaluating regression models, read Which metrics are used to evaluate a regression model's performance?
Feature Importance
The Insights tab also contains the Feature Importance page, which can provide insight into the most important factors contributing to CLV.
Feature importance page under Insights tab
Prediction Explanation
The next page under the Insights tab is Prediction Explanation. This feature allows you to examine the models CLV prediction of a given customer, providing what factors increase or decrease their likelihood of churning, and to what extent.
Prediction explanation page under Insights tab
Customer details window, accessible by clicking view details for any customer in Prediction explanation.
🎓For more information about feature importance and prediction explanations, read Gain insights from predictions with Feature Importance, Prediction Explanation and What-If Analysis
Making predictions
The predictions from the Customer Lifetime Value Prediction ML Solution Template provide following:
-
A list of current customers.
-
The timestamp at which time the customer lifetime value is predicted.
-
The customer lifetime value for each of them.
-
The factors that are used to calculate the value.
To initiate a prediction, click the Make predictions button on the App overview page. You have the option to select either a One-time prediction to quickly make a single prediction, or Periodically scheduled predictions, which generates predictions at regular intervals.
With both options, you’ll need to provide the same data sources you provided when creating the application. In this example, both:
-
Transaction data
-
Customer information
Provide input data sources for predictions
For the scheduled periodic prediction option, you also need to select the frequency that the Engine will perform the prediction.
Provide schedule for periodic predictions
Once these steps are completed, you can click Run prediction to start the prediction process which will direct you to the Prediction details page. You can see the prediction status in this Prediction details page or in the App details page.
Processing Status on the App details page
Once the prediction status changes to Ready, you can consume the predictions in three ways.
-
Preview a sample of the output
-
Download the output as a csv, json lines or parquet file
-
Export output to a dataset within the Engine or to an external database
Preview of the prediction output
To learn more about the supported options for prediction, read What are the options for predictions for Machine Learning Solution Templates?
Conclusion
In this article, a walkthrough is provided on how the AI & Analytics Engine can assist you in predicting customer lifetime value for a business with transactional activities with an efficient and effective solution. In order to create a CLV prediction model, you only need to upload your raw datasets and define a few configuration features, which was illustrated using a banking scenario. This enables you to understand your customers' behaviors, and develop appropriate strategies to maximise the value of the customer relationship.