Complete Technical Paper Content โ Customer Lifetime Value Prediction
1. Executive Abstract, Problem Formulation & Background
Customer-Lifetime-Value-Prediction Understanding and predicting Customer Lifetime Value (CLV) is a key driver of strategic decision-making in retail, enabling organizations to identify high-value customers, tailor marketing campaigns, and optimize resource allocation. This project develops deep learning models to accurately estimate CLV for individual customers, defined as the total amount spent across all their transactions. The models leverage both demographic data and behavioral features aggregated at the customer level. The dataset underwent rigorous preprocessing, including outlier detection, log-transformations for skewed variables, handling rare categories, and feature engineering to extract meaningful insights such as product category diversity and transaction history. Numerical and categorical features were prepared for model input using scaling, embedding, and grouping techniques as appropriate. Deep Learning Approaches This project implements three advanced deep learning approaches for CLV prediction: Tabular Neural Network with Embeddings A traditional feedforward neural network that leverages learned embeddings for categorical features and direct processing of numerical features. The architecture includes multiple dense layers with dropout regularization, optimized through Bayesian hyperparameter tuning. FTTransformer An attention-based transformer model specifically tailored for tabular data. This model tokenizes both categorical and numerical features into embeddings and processes them through transformer blocks, capturing complex feature interactions through self-attention mechanisms. Hybrid Residual Learning Model A novel sequential ensemble approach that combines the strengths of both architectures through residual learning. The method works in two stages: Train the FTTransformer to capture primary patterns and complex feature interactions. Train the Tabular Neural Network on the residuals from the FTTransformer to capture systematic patterns that the transformer missed. This hybrid approach leverages the transformer's ability to model complex relationships while utilizing the tabular network's effectiveness at capturing local patterns and categorical embeddings. Model Performance (MAPE) Tabular Neural Network: 8.38% FTTransformer: 7.33% Hybrid Model: 2.29% This work demonstrates the power of deep learning for CLV prediction and underscores the value of data-driven strategies in enhancing customer management, retention, and targeted growth in the retail sector.
Understanding and predicting Customer Lifetime Value (CLV) is a key driver of strategic decision-making in retail, enabling organizations to identify high-value customers, tailor marketing campaigns, and optimize resource allocation. This project develops deep learning models to accurately estimate CLV for individual customers, defined as the total amount spent across all their transactions. The models leverage both demographic data and behavioral features aggregated at the customer level.
The dataset underwent rigorous preprocessing, including outlier detection, log-transformations for skewed variables, handling rare categories, and feature engineering to extract meaningful insights such as product category diversity and transaction history. Numerical and categorical features were prepared for model input using scaling, embedding, and grouping techniques as appropriate.
Tabular Neural Network with Embeddings A traditional feedforward neural network that leverages learned embeddings for categorical features and direct processing of numerical features. The architecture includes multiple dense layers with dropout regularization, optimized through Bayesian hyperparameter tuning.
FTTransformer An attention-based transformer model specifically tailored for tabular data. This model tokenizes both categorical and numerical features into embeddings and processes them through transformer blocks, capturing complex feature interactions through self-attention mechanisms.
Hybrid Residual Learning Model A novel sequential ensemble approach that combines the strengths of both architectures through residual learning. The method works in two stages: Train the FTTransformer to capture primary patterns and complex feature interactions. Train the Tabular Neural Network on the residuals from the FTTransformer to capture systematic patterns that the transformer missed. This hybrid approach leverages the transformer's ability to model complex relationships while utilizing the tabular network's effectiveness at capturing local patterns and categorical embeddings.
2. Related Work, Literature Survey & Algorithmic Foundations
This work demonstrates the power of deep learning for CLV prediction and underscores the value of data-driven strategies in enhancing customer management, retention, and targeted growth in the retail sector.
Customer Lifetime Value (CLV) Prediction An End-to-End Machine Learning System for Predicting Customer Lifetime Value and Enabling Data-Driven Customer Retention ๐ Overview Customer Lifetime Value (CLV) is one of the most important business metrics in customer analytics, representing the total revenue a customer is expected to generate over their relationship with a company. Accurately estimating CLV enables businesses to identify high-value customers, optimize marketing investments, improve customer retention, and make data-driven strategic decisions. In this project, an end-to-end machine learning pipeline is developed to predict the next 90-day Customer Lifetime Value using historical e-commerce transaction data. The solution includes data preprocessing, customer-level feature engineering, time-based validation to prevent data leakage, model development, and performance evaluation, demonstrating how predictive analytics can support customer retention, marketing optimization, and revenue forecasting in e-commerce. ๐ฏ Business Problem Acquiring new customers is significantly more expensive than retaining existing ones. Businesses therefore need to identify customers who are likely to generate the highest future revenue. The objective of this project is to predict the next 90-day Customer Lifetime Value (CLV) of each customer using historical transaction data. These predictions can support personalized marketing campaigns, customer segmentation, and more efficient allocation of marketing resources. ๐ Dataset This project uses an e-commerce transaction dataset containing historical customer purchase records. The dataset includes information such as: Customer ID Invoice Date Product Quantity Unit Price Purchase Amount Transaction History From these raw transactions, customer-level features such as Recency, Frequency, Monetary Value (RFM), Average Order Value, and Purchase Count were engineered for model training. A time-based cutoff strategy was applied to predict each customer's revenue over the following 90 days while preventing data leakage. ๐ Technologies Used Python Pandas NumPy Scikit-learn Matplotlib โ๏ธ Methodology Data Collection and Understanding Data Cleaning and Preprocessing Customer-Level Feature Engineering (RFM Metrics) Exploratory Data Analysis (EDA) Time-Based Train-Test Split Machine Learning Model Development Model Evaluation and Error Analysis Customer Value Segmentation Business Insights and Recommendations Feature Engineering Features created include: Past Revenue Past Transactions Recency Customer Age Average Order Value Purchase Frequency Models Used Linear Regression Random Forest Regressor Gradient Boosting Regressor Evaluation Metrics Mean Absolute Error (MAE) Root Mean Squared Error (RMSE) Rยฒ Score Best Tuned Random Forest Results: MAE: 1049.67 RMSE: 7549.55 Rยฒ Score: 0.124 Technologies Used Python Pandas NumPy Matplotlib Seaborn Scikit-learn Jupyter Notebook ๐ Results The Random Forest Regressor achieved the best overall performance compared to the baseline model on the time-based validation set. Key outcomes include: Accurate prediction of 90-day customer revenue Identification of high-value customer segments Improved understanding of purchasing behavior through engineered customer-level features A reusable machine learning pipeline for future customer value prediction ๐ Future Improvements Deploy the model using Streamlit and FastAPI Add SHAP-based explainability for model predictions Compare advanced models such as XGBoost and LightGBM Integrate automated retraining pipelines Deploy using Docker and cloud services Build an interactive business dashboard for marketing teams
Customer Lifetime Value (CLV) is one of the most important business metrics in customer analytics, representing the total revenue a customer is expected to generate over their relationship with a company. Accurately estimating CLV enables businesses to identify high-value customers, optimize marketing investments, improve customer retention, and make data-driven strategic decisions.
In this project, an end-to-end machine learning pipeline is developed to predict the next 90-day Customer Lifetime Value using historical e-commerce transaction data. The solution includes data preprocessing, customer-level feature engineering, time-based validation to prevent data leakage, model development, and performance evaluation, demonstrating how predictive analytics can support customer retention, marketing optimization, and revenue forecasting in e-commerce.
Acquiring new customers is significantly more expensive than retaining existing ones. Businesses therefore need to identify customers who are likely to generate the highest future revenue.
The objective of this project is to predict the next 90-day Customer Lifetime Value (CLV) of each customer using historical transaction data. These predictions can support personalized marketing campaigns, customer segmentation, and more efficient allocation of marketing resources.
3. Dataset Ingestion, Preprocessing & Stochastic Augmentations
This project uses an e-commerce transaction dataset containing historical customer purchase records.
From these raw transactions, customer-level features such as Recency, Frequency, Monetary Value (RFM), Average Order Value, and Purchase Count were engineered for model training.
A time-based cutoff strategy was applied to predict each customer's revenue over the following 90 days while preventing data leakage.
The Random Forest Regressor achieved the best overall performance compared to the baseline model on the time-based validation set.
Machine learning project to predict Customer Lifetime Value (CLV) using transactional and behavioral data.
Customer Lifetime Value (LTV) Prediction Model Project Overview This project implements a machine learning model to predict Customer Lifetime Value (LTV) based on purchase behavior, enabling targeted marketing strategies and customer segmentation. Key Results Model Performance Model MAE RMSE Rยฒ Score Linear Regression 245.32 412.18 0.7234 Random Forest 198.76 356.42 0.8156 XGBoost (Tuned) 187.23 334.91 0.8342 Customer Segmentation RFM Analysis showing customer distribution across Recency, Frequency, and Monetary dimensions Feature Importance Key drivers of Customer Lifetime Value identified by the XGBoost model Model Comparison Performance comparison across different machine learning algorithms Tools & Technologies Python : Primary programming language Scikit-learn : Machine learning framework XGBoost : Gradient boosting algorithm for regression Pandas : Data manipulation and analysis Matplotlib/Seaborn : Data visualization Jupyter Notebook : Development environment Project Structure Customer-LTV-Prediction/ โโโ README.md # Project documentation โโโ requirements.txt # Python dependencies โโโ Customer_LTV_Prediction_Report.pdf โโโ data/ โ โโโ OnlineRetail.csv # Raw dataset (541K+ transactions) โโโ notebooks/ โ โโโ 01_EDA_and_RFM_Analysis.ipynb # Exploratory Data Analysis โ โโโ 02_RFM_Feature_Engineering.ipynb # Feature engineering โ โโโ 03_LTV_Model_Training.ipynb # Model training & evaluation โโโ results/ โ โโโ data_cleaned.csv # Preprocessed data โ โโโ customer_summary.csv # Customer statistics โ โโโ rfm_features.csv # RFM features โ โโโ final_ltv_predictions.csv # Final predictions โโโ visualizations/ โโโ feature_correlation.png # Feature correlation matrix โโโ rfm_analysis.png # RFM analysis charts โโโ model_comparison.png # Model performance comparison โโโ final_ltv_analysis.png # Final analysis visualizations Quick Start Installation git clone https://github.com/Srusti-26/Customer-LTV-Prediction.git cd Customer-LTV-Prediction pip install -r requirements.txt Usage # 1. Run EDA and RFM Analysis jupyter notebook notebooks/01_EDA_and_RFM_Analysis.ipynb # 2. Feature Engineering jupyter notebook notebooks/02_RFM_Feature_Engineering.ipynb # 3. Model Training and Prediction jupyter notebook notebooks/03_LTV_Model_Training.ipynb Methodology 1. Data Preprocessing Remove missing CustomerIDs (135K records) Handle negative quantities/prices Calculate transaction amounts Remove outliers using IQR method 2. Feature Engineering RFM Analysis : Recency, Frequency, Monetary features Customer Metrics : AOV, Tenure, Product Diversity Derived Features : RFM Scores, Purchase Patterns Total Features : 15+ behavioral indicators 3. Model Training Baseline : Linear Regression Ensemble : Random Forest Regressor Primary : XGBoost with hyperparameter tuning Validation : 80-20 train-test split + 3-fold CV 4. Customer Segmentation Segment Count Avg LTV Description Champions 342 $4,247 Best customers - high value, frequent Loyal Customers 789 $2,156 Regular buyers with good value Potential Loyalists 1,234 $1,432 Recent customers with potential At Risk 567 $987 Valuable but haven't purchased recently Hibernating 1,440 $234 Lost customers - need reactivation Business Impact Key Insights Top 20% customers generate 67% of total revenue Monetary value is the strongest LTV predictor (importance: 0.34) Purchase frequency shows 0.78 correlation with LTV Customer tenure averages 133 days with high variance Actionable Recommendations Focus marketing budget on Champions and Loyal segments Reactivation campaigns for At Risk customers Retention programs for Potential Loyalists Personalized offers based on predicted LTV Results & Performance Final Model Metrics Mean Absolute Error : 187.23 Root Mean Square Error : 334.91 Rยฒ Score : 0.8342 (83.42% variance explained) Customers Analyzed : 4,372 Prediction Accuracy : 84.7% within ยฑ20% range Model Validation Strong correlation between actual and predicted LTV values Future Enhancements Time-series forecasting for dynamic LTV Real-time prediction API A/B testing framework Advanced clustering algorithms Integration with CRM systems Dataset Information Source : UCI Machine Learning Repository Period : December 2010 - December 2011 Records : 541,909 transactions Customers : 4,372 unique customers Countries : 37 countries (mainly UK) Contributing Fork the repository Create feature branch ( git checkout -b feature/AmazingFeature ) Commit changes ( git commit -m 'Add AmazingFeature' ) Push to branch ( git push origin feature/AmazingFeature ) Open Pull Request License This project is licensed under the MIT License - see the LICENSE file for details. Contact Author : Srusti Email : 1nt23ad052.srusti@nmit.ac.in LinkedIn : Srusti's LinkedIn Profile Project Link : https://github.com/srusti/Customer-LTV-Prediction โญ Star this repository if it helped you!
4. Neural Network Backbone, Layer Specifications & Loss Formulations
This project implements a machine learning model to predict Customer Lifetime Value (LTV) based on purchase behavior, enabling targeted marketing strategies and customer segmentation.
RFM Analysis showing customer distribution across Recency, Frequency, and Monetary dimensions
Customer-LTV-Prediction/ โโโ README.md # Project documentation โโโ requirements.txt # Python dependencies โโโ Customer_LTV_Prediction_Report.pdf โโโ data/ โ โโโ OnlineRetail.csv # Raw dataset (541K+ transactions) โโโ notebooks/ โ โโโ 01_EDA_and_RFM_Analysis.ipynb # Exploratory Data Analysis โ โโโ 02_RFM_Feature_Engineering.ipynb # Feature engineering โ โโโ 03_LTV_Model_Training.ipynb # Model training & evaluation โโโ results/ โ โโโ data_cleaned.csv # Preprocessed data โ โโโ customer_summary.csv # Customer statistics โ โโโ rfm_features.csv # RFM features โ โโโ final_ltv_predictions.csv # Final predictions โโโ visualizations/ โโโ feature_correlation.png # Feature correlation matrix โโโ rfm_analysis.png # RFM analysis charts โโโ model_comparison.png # Model performance comparison โโโ final_ltv_analysis.png # Final analysis visualizations
git clone https://github.com/Srusti-26/Customer-LTV-Prediction.git cd Customer-LTV-Prediction pip install -r requirements.txt
# 1. Run EDA and RFM Analysis jupyter notebook notebooks/01_EDA_and_RFM_Analysis.ipynb # 2. Feature Engineering jupyter notebook notebooks/02_RFM_Feature_Engineering.ipynb # 3. Model Training and Prediction jupyter notebook notebooks/03_LTV_Model_Training.ipynb
Customer Lifetime Value (CLV) Prediction This repository contains an end-to-end pipeline for predicting Customer Lifetime Value (CLV) using the Online Retail Dataset . The model leverages Artificial Neural Networks (ANN) for prediction and utilizes MLflow for robust experiment tracking and reproducibility. Overview Customer Lifetime Value (CLV) is a key business metric that estimates the total net profit attributed to the entire future relationship with a customer. Predicting CLV enables better: Marketing strategy formulation Customer segmentation Retention campaign targeting Revenue forecasting This project includes data processing, modeling, training, evaluation, and experiment tracking. Dataset Description The Online Retail Dataset is a real-world e-commerce transaction dataset that contains: Country : Country of customer residence InvoiceDate : Date of transaction CustomerID : Unique identifier for each customer InvoiceNo : Unique invoice number per transaction StockCode : Product identifier Description : Product description Quantity : Quantity of items purchased UnitPrice : Price per item Sources : UCI: https://archive.ics.uci.edu/dataset/352/online+retail Kaggle: Search for "Online Retail Dataset" Problem Statement The goal is to predict the monetary value of a customer's future purchases , using historical data. We approach this as a regression problem , where the target is the total value a customer is expected to generate over a defined horizon. Modeling Approach Feature Engineering Key features engineered include: Recency, Frequency, Monetary (RFM) metrics Customer tenure Purchase patterns Time-based aggregations Model Architecture: Artificial Neural Network (ANN) Input layer aligned with number of engineered features 2โ3 hidden layers with ReLU activation Output layer with linear activation for regression Optimized with Adam, MSE loss function Training Pipeline Data preprocessing using pandas and scikit-learn Train/validation split Training monitored and logged with MLflow Model persisted and versioned for reproducibility Tools & Frameworks Tool Purpose Python Core programming language Pandas Data manipulation NumPy Numerical computation Scikit-learn Preprocessing utilities TensorFlow/Keras or PyTorch Model implementation MLflow Experiment tracking and model registry MLflow Tracking MLflow is used to: Log metrics like loss, MAE, RMSE Track hyperparameters Save and register models Compare different model runs visually Example: mlflow ui Access the MLflow dashboard at http://localhost:5000 to explore and compare experiments. Results The ANN-based model demonstrated strong generalization capability, especially when fine-tuned with: Proper scaling and feature normalization Balanced mini-batches during training Dropout regularization to prevent overfitting References UCI ML Repository: Online Retail Data Set Kaggle: Online Retail Dataset MLflow Documentation CLV Theory - Harvard Business Review Future Improvements Integrate RFM-based customer segmentation prior to modeling Use sequence models (RNNs) for purchase pattern learning Deploy the model as a REST API with FastAPI or Flask Extend to real-time prediction for live transactions
5. Training Protocol, Convergence Behavior & Experimental Evaluation
This repository contains an end-to-end pipeline for predicting Customer Lifetime Value (CLV) using the Online Retail Dataset . The model leverages Artificial Neural Networks (ANN) for prediction and utilizes MLflow for robust experiment tracking and reproducibility.
Customer Lifetime Value (CLV) is a key business metric that estimates the total net profit attributed to the entire future relationship with a customer. Predicting CLV enables better:
This project includes data processing, modeling, training, evaluation, and experiment tracking.
The Online Retail Dataset is a real-world e-commerce transaction dataset that contains:
The goal is to predict the monetary value of a customer's future purchases , using historical data. We approach this as a regression problem , where the target is the total value a customer is expected to generate over a defined horizon.
mlflow ui Access the MLflow dashboard at http://localhost:5000 to explore and compare experiments.
Model Figures & Evaluation Curves (4 Images)
Deep Learning Execution Pipeline
(Preprocessing)
(Feature Extraction)
(Self-Attention)
(Loss Optimization)