Enio Rubens da Silva Maria














Sign up
Beta
Spinner

Customer Lifetime Value

E-Commerce Data

This dataset consists of orders made in different countries from December 2010 to December 2011. The company is a UK-based online retailer that mainly sells unique all-occasion gifts, with many of its customers being wholesalers.

import pandas as pd
data = pd.read_csv('online_retail.csv', parse_dates = ['InvoiceDate'])
pd.read_csv('variable_explanation.csv')

Source of dataset.

Citation: Daqing Chen, Sai Liang Sain, and Kun Guo, Data mining for the online retail industry: A case study of RFM model-based customer segmentation using data mining, Journal of Database Marketing and Customer Strategy Management, Vol. 19, No. 3, pp. 197-208, 2012 (Published online before print: 27 August 2012. doi: 10.1057/dbm.2012.17).

data.describe()

Here, we can observe some of the customers have ordered in a negative quantity, centanly is about damage or for some reason a devolution. So, we need to filter Quantity greater than zero.

# droping price zero and below zero
data = data.drop(data[data.UnitPrice == 0].index)
data = data.drop(data[data.UnitPrice < 0].index)

# droping Quantity zero and below zero. Certanly it is about damage or quantity wrong.
data = data.drop(data[data.Quantity == 0 ].index)
data = data.drop(data[data.Quantity < 0 ].index)

data.describe()

Customer Lifetime Value

Italian economist Vilfredo Pareto states that 80% of the effect comes from 20% of the causes, this is known as 80/20 rule or Pareto principle. Similarly, 80% of companies business comes from 20% customers. Companies need to identify those top customers and maintain the relationship with them to ensure continuous revenue. In order to maintain a long-term relationship with customers, companies need to schedule loyalty schemes such as the discount, offers, coupons, bonus point, and gifts.

Targeting a new customer is more costly than retaining existing customers because you don’t need to spend resources, time, and work hard to acquire new customers. You just have to keep the existing customers happy. Business analyst's accurately calculate customer acquisition cost using CLTV(Customer Lifetime Value). CLTV indicates the total revenue from the customer during the entire relationship. CLTV helps companies to focus on those potential customers who can bring in the more revenue in the future.

In this tutorial, you are going to cover the following topics:

  • Introduction
  • Customer Lifetime value(CLTV)
  • Related Work of CLTV
  • CLTV Formulas
  • Implementing CLTV in Python

Customer Lifetime Value(CLTV)

Customer Lifetime Value is a monetary value that represents the amount of revenue or profit a customer will give the company over the period of the relationship". CLTV demonstrates the implications of acquiring long-term customers compare to short-term customers. Customer lifetime value (CLV) can help you to answers the most important questions about sales to every company:

  • How to Identify the most profitable customers?
  • How can a company offer the best product and make the most money?
  • How to segment profitable customers?
  • How much budget need to spend to acquire customers?
# import modules
import pandas as pd # for dataframes
import matplotlib.pyplot as plt # for plotting graphs
import seaborn as sns # for plotting graphs
import datetime as dt
import numpy as np

Top 10 customer

#Top ten country's customer
data.Country.value_counts()[:10].plot(kind='bar')

In the given dataset, we can observe most of the customers are from "United Kingdom". So, I will filter data for United Kingdom customer.

uk_data=data[data.Country=='United Kingdom']
uk_data.describe()

Pre processing.

How many Customers we have ?

total_customer = data.CustomerID.nunique()
print('Total of customer that have been purchasing from us : {}'.format(total_customer))
customer_top_20 = int(total_customer * 0.2)
print('Thus, 20% is about : {} customers'.format(customer_top_20))



  • AI Chat
  • Code