数据驱动分析实践三 Customer Lifetime Value

发布时间:2025-02-28 01:01

数据驱动决策:利用数据分析优化战略 #生活技巧# #领导力技巧# #战略规划能力#

数据驱动分析三

Customer Lifetime Value

    上一篇我们探讨了如何进行客户分段,并介绍了RFM方法。本篇我们进入了本系列最重要的主题,如何估算CLV(Customer Lifetime Value)。关于CLV的基本概念和理论,读者可参见本人的另外系列文章用户存续期价值评估

    事实上,我们经常在客户上投入以获得收入及利润,例如获客成本、线下广告、宣传活动和折扣等。这些活动自然而然地会产生价值非常高的客户,当然也会存在降低利润的客户。我们需要辨别出这些不同客户的行为特点,进行客户分段并采取相应的行为。

    计算CLV并不是一个很难的事,一般我们可以选定一个时间窗口,按照下面的公式计算。
CLV = Total Gross Value - Total cost

    这个公式只能告诉我们历史信息,当发现一个客户的价值为负时,可能已经太晚了。在这种情况下,我们尝试使用机器学习来预测未来的CLV.

预测CLV

    我们将采用如下步骤:

为CLV的计算定义时间窗口 特征工程 构建和训练机器学习模型 运行模型 检验模型有效性

    如何定义时间窗口依赖于所在行业、商业模式、战略等因素。对某些行业来说,一年已经是较长的时间窗口了,但对于另外一些行业就属于比较短的窗口。我们在这个演示例子中使用6个月的时间窗口。

    在上一篇文章中,我们已经为每一个客户计算过了RFM评分,这个分数是一个良好的特征。本文中,我们将会拆分我们的数据集,计算三个月的RFM且使用它来计算下六个月的值。

#import libraries from __future__ import division from datetime import datetime, timedelta,date import pandas as pd %matplotlib inline from sklearn.metrics import classification_report,confusion_matrix import matplotlib.pyplot as plt import numpy as np import seaborn as sns from sklearn.cluster import KMeans import chart_studio.plotly as py import plotly.offline as pyoff import plotly.graph_objs as go #import plotly.plotly as py #import plotly.offline as pyoff #import plotly.graph_objs as go import xgboost as xgb from sklearn.model_selection import KFold, cross_val_score, train_test_split import xgboost as xgb #initate plotly pyoff.init_notebook_mode() #read data from csv and redo the data work we done before tx_data = pd.read_excel('Online Retail.xlsx') tx_data['InvoiceDate'] = pd.to_datetime(tx_data['InvoiceDate']) tx_uk = tx_data.query("Country=='United Kingdom'").reset_index(drop=True) #create 3m and 6m dataframes tx_3m = tx_uk[(tx_uk.InvoiceDate < datetime(2011,6,1)) & (tx_uk.InvoiceDate >= datetime(2011,3,1))].reset_index(drop=True) tx_6m = tx_uk[(tx_uk.InvoiceDate >= datetime(2011,6,1)) & (tx_uk.InvoiceDate < datetime(2011,12,1))].reset_index(drop=True) #create tx_user for assigning clustering tx_user = pd.DataFrame(tx_3m['CustomerID'].unique()) tx_user.columns = ['CustomerID'] #order cluster method def order_cluster(cluster_field_name, target_field_name,df,ascending): new_cluster_field_name = 'new_' + cluster_field_name df_new = df.groupby(cluster_field_name)[target_field_name].mean().reset_index() df_new = df_new.sort_values(by=target_field_name,ascending=

1234567891011121314151617181920212223242526272829303132333435363738394041424344

网址:数据驱动分析实践三 Customer Lifetime Value https://www.yuejiaxmz.com/news/view/798412

相关内容

数据驱动的智库知识服务流程优化
智能分析:引领数据驱动决策的科技新时代
数据驱动决策:从理论到实践
什么是数据驱动?如何实现数据驱动?
数据分析
Oracle数据库高效数据清洗策略与实践案例分析
【数据驱动】数据驱动学习与动态系统控制Matlab实现
什么是数据驱动,如何才算实现数据驱动?
数据驱动的数字化转型:从流程驱动到数据驱动
什么是数据驱动?它和模型驱动、领域驱动、元数据驱动、DSL驱动之间有什么区别?

随便看看