RFM模型是互联网衡量当前用户价值和客户潜在价值的重要工具和手段。RFM是Rencency(最近一次消费),Frequency(消费频率)、Monetary(消费金额),三个指标首字母组合。
本次数据中通过最近消费(R)和消费频率(F)建⽴RFM模型:
- 重要⾼价值客户:指最近⼀次消费较近⽽且消费频率较⾼的客户;
- 重要唤回客户:指最近⼀次消费较远且消费频率较⾼的客户;
- 重要深耕客户:指最近⼀次消费较近且消费频率较低的客户;
- 重要挽留客户:指最近⼀次消费较远且消费频率较低的客户;
1 R计算
-- 获取用户最近的购买时间
create view user_recency as
select user_id,max(dates) recent_buy_time from temp_trade where behavior_type ='2' group by user_id
-- 计算每个用户的最近购买时间与2019-12-18相差几天,并根据天数给予分数
create view r_level as
select user_id,recent_buy_time,datediff('2019-12-18',recent_buy_time),
case when datediff('2019-12-18',recent_buy_time)<'2' then '5'
when datediff('2019-12-18',recent_buy_time)<='4' then '4'
when datediff('2019-12-18',recent_buy_time)<='6' then '3'
when datediff('2019-12-18',recent_buy_time)<='8' then '2'
else '1' end as r_value
from user_recency
order by recent_buy_time
2 F计算
-- 获取用户购买次数
create view user_buy_frequency as
select user_id,count(behavior_type) buy_frequency from temp_trade where behavior_type ='2' group by user_id
-- 对购买次数进行打分
create view f_level as
select user_id,buy_frenquecy,
(case
when buy_frenquecy<=2 then 1
when buy_frenquecy<=4 then 2
when buy_frenquecy<=6 then 3
when buy_frenquecy<=8 then 4
else 5 end) f_value
from user_buy_frequency
3 整合
-- R与F整合分类用户
select avg(r_value) r_avg from r_level; -- 2.7939
select avg(f_value) f_avg from f_level; -- 2.2606
select r.user_id,r.r_value,f_value,
(case
when r.r_value>2.7939 and f.f_value>2.266 then '重要价值客户'
when r.r_value<2.7939 and f.f_value>2.266 then '重要唤回客户'
when r.r_value>2.7939 and f.f_value<2.266 then '重要深耕客户'
when r.r_value<2.7939 and f.f_value<2.266 then '重要挽留客户'
end) r_f_value -- 没有其他结果时,就不加else
from r_level r inner join f_level f on r.user_id=f.user_id
本文经授权发布,不代表增长黑客立场,如若转载,请注明出处:https://www.growthhk.cn/quan/76768.html