最近、频率、金额(RFM)分群

Python 中的客户细分

Karolis Urbonas

Head of Data Science, Amazon

什么是 RFM 分群?

基于三项指标的行为分群:

  • 最近度(R)
  • 频率(F)
  • 金额(M)
Python 中的客户细分

RFM 值的分组

RFM 可按多种方式分组:

  • 百分位,如分位数
  • 帕累托 80/20 切分
  • 自定义——基于业务知识

我们将实现基于百分位的分组。

Python 中的客户细分

百分位速览

计算百分位的流程:

  1. 按该指标对客户排序
  2. 划分为预设数量、等大小的组
  3. 为每组分配标签
Python 中的客户细分

用 Python 计算百分位

包含 8 个 CustomerID 和随机计算的 Spend 值的数据。

dummy_percentile_data

Python 中的客户细分

用 Python 计算百分位

spend_quartiles = pd.qcut(data['Spend'], q=4, labels=range(1,5))

data['Spend_Quartile'] = spend_quartiles
data.sort_values('Spend')

Python 中的客户细分

分配标签

  • 最高分给最佳指标——最佳不一定最高,如最近度
  • 此处标签取反——越近期的客户越好

Python 中的客户细分

分配标签

# Create numbered labels
r_labels = list(range(4, 0, -1))

# Divide into groups based on quartiles recency_quartiles = pd.qcut(data['Recency_Days'], q=4, labels=r_labels)
# Create new column data['Recency_Quartile'] = recency_quartiles
# Sort recency values from lowest to highest data.sort_values('Recency_Days')
Python 中的客户细分

分配标签

如图,四分位标签是反向的,因为更近期的客户更有价值。

recency_quartiles

Python 中的客户细分

自定义标签

可按用例用字符串或其他值定义列表。

# Create string labels
r_labels = ['Active', 'Lapsed', 'Inactive', 'Churned']

# Divide into groups based on quartiles recency_quartiles = pd.qcut(data['Recency_Days'], q=4, labels=r_labels) # Create new column data['Recency_Quartile'] = recency_quartiles # Sort values from lowest to highest data.sort_values('Recency_Days')
Python 中的客户细分

自定义标签

为各四分位分配自定义标签

Recency_quartiles

Python 中的客户细分

用百分位来练习!

Python 中的客户细分

Preparing Video For Download...