2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > 【毕业设计】大数据电商用户行为数据分析与可视化

【毕业设计】大数据电商用户行为数据分析与可视化

时间:2021-06-03 23:10:12

相关推荐

【毕业设计】大数据电商用户行为数据分析与可视化

文章目录

0 前言1 数据集说明2 数据处理2.1 数据导入2.2 数据清洗 3 数据分析可视化3.1 用户流量及购物情况3.2 用户行为转换率3.3 用户行为习惯3.4 基于 RFM 模型找出有价值的用户3.5 商品维度的分析 4 最后

0 前言

🔥 Hi,大家好,这里是丹成学长的毕设系列文章!

🔥 对毕设有任何疑问都可以问学长哦!

这两年开始,各个学校对毕设的要求越来越高,难度也越来越大… 毕业设计耗费时间,耗费精力,甚至有些题目即使是专业的老师或者硕士生也需要很长时间,所以一旦发现问题,一定要提前准备,避免到后面措手不及,草草了事。

为了大家能够顺利以及最少的精力通过毕设,学长分享优质毕业设计项目,今天要分享的新项目是

🚩大数据电商用户行为分析与可视化

🥇学长这里给一个题目综合评分(每项满分5分)

难度系数:4分工作量:4分创新点:3分

🧿选题指导, 项目分享:

/yaa-dc/BJH/blob/master/gg/cc/README.md

1 数据集说明

这是一份来自淘宝的用户行为数据,时间区间为 -11-25 到 -12-03,总计 100,150,807 条记录,大小为 3.5 G,包含 5 个字段。

2 数据处理

2.1 数据导入

将数据加载到 hive, 然后通过 hive 对数据进行数据处理。

-- 建表drop table if exists user_behavior;create table user_behavior (`user_id` string comment '用户ID',`item_id` string comment '商品ID',`category_id` string comment '商品类目ID',`behavior_type` string comment '行为类型,枚举类型,包括(pv, buy, cart, fav)',`timestamp` int comment '行为时间戳',`datetime` string comment '行为时间')row format delimitedfields terminated by ','lines terminated by '\n';-- 加载数据LOAD DATA LOCAL INPATH '/home/getway/UserBehavior.csv'OVERWRITE INTO TABLE user_behavior ;

2.2 数据清洗

数据处理主要包括:删除重复值,时间戳格式化,删除异常值。

--数据清洗,去掉完全重复的数据insert overwrite table user_behaviorselect user_id, item_id, category_id, behavior_type, timestamp, datetimefrom user_behaviorgroup by user_id, item_id, category_id, behavior_type, timestamp, datetime;--数据清洗,时间戳格式化成 datetimeinsert overwrite table user_behaviorselect user_id, item_id, category_id, behavior_type, timestamp, from_unixtime(timestamp, 'yyyy-MM-dd HH:mm:ss')from user_behavior;--查看时间是否有异常值select date(datetime) as day from user_behavior group by date(datetime) order by day;--数据清洗,去掉时间异常的数据insert overwrite table user_behaviorselect user_id, item_id, category_id, behavior_type, timestamp, datetimefrom user_behaviorwhere cast(datetime as date) between '-11-25' and '-12-03';--查看 behavior_type 是否有异常值select behavior_type from user_behavior group by behavior_type;

3 数据分析可视化

3.1 用户流量及购物情况

--总访问量PV,总用户量UVselect sum(case when behavior_type = 'pv' then 1 else 0 end) as pv,count(distinct user_id) as uvfrom user_behavior;

--日均访问量,日均用户量select cast(datetime as date) as day,sum(case when behavior_type = 'pv' then 1 else 0 end) as pv,count(distinct user_id) as uvfrom user_behaviorgroup by cast(datetime as date)order by day;

--每个用户的购物情况,加工到 user_behavior_countcreate table user_behavior_count asselect user_id,sum(case when behavior_type = 'pv' then 1 else 0 end) as pv, --点击数sum(case when behavior_type = 'fav' then 1 else 0 end) as fav, --收藏数sum(case when behavior_type = 'cart' then 1 else 0 end) as cart, --加购物车数sum(case when behavior_type = 'buy' then 1 else 0 end) as buy --购买数from user_behaviorgroup by user_id;--复购率:产生两次或两次以上购买的用户占购买用户的比例select sum(case when buy > 1 then 1 else 0 end) / sum(case when buy > 0 then 1 else 0 end)from user_behavior_count;

小结:-11-25 到 -12-03 这段时间,PV 总数为 89,660,671 ,UV 总数为 987,991。从日均访问量趋势来看,进入 12 月份之后有一个比较明显的增长,猜测可能是因为临近双 12 ,电商活动引流产生,另外,-12-02 和 -12-03 刚好是周末,也可能是周末的用户活跃度本来就比平常高。总体的复购率为 66.01%,说明用户的忠诚度比较高。

3.2 用户行为转换率

--点击/(加购物车+收藏)/购买 , 各环节转化率select a.pv,a.fav,a.cart,a.fav + a.cart as `fav+cart`,a.buy,round((a.fav + a.cart) / a.pv, 4) as pv2favcart,round(a.buy / (a.fav + a.cart), 4) as favcart2buy,round(a.buy / a.pv, 4) as pv2buyfrom(select sum(pv) as pv, --点击数sum(fav) as fav, --收藏数sum(cart) as cart, --加购物车数sum(buy) as buy --购买数from user_behavior_count) as a;

小结:-11-25 到 -12-03 这段时间,点击数为 89,660,671 ,收藏数为 2,888,258,加购物车数为5,530,446,购买数为 2,015,807。总体的转化率为 2.25%,这个值可能是比较低的,从加到购物车数来看,有可能部分用户是准备等到电商节日活动才进行购买。所以合理推断:一般电商节前一段时间的转化率会比平常低。

3.3 用户行为习惯

-- 一天的活跃时段分布select hour(datetime) as hour,sum(case when behavior_type = 'pv' then 1 else 0 end) as pv, --点击数sum(case when behavior_type = 'fav' then 1 else 0 end) as fav, --收藏数sum(case when behavior_type = 'cart' then 1 else 0 end) as cart, --加购物车数sum(case when behavior_type = 'buy' then 1 else 0 end) as buy --购买数from user_behaviorgroup by hour(datetime)order by hour;

--一周用户的活跃分布select pmod(datediff(datetime, '1920-01-01') - 3, 7) as weekday,sum(case when behavior_type = 'pv' then 1 else 0 end) as pv, --点击数sum(case when behavior_type = 'fav' then 1 else 0 end) as fav, --收藏数sum(case when behavior_type = 'cart' then 1 else 0 end) as cart, --加购物车数sum(case when behavior_type = 'buy' then 1 else 0 end) as buy --购买数from user_behaviorwhere date(datetime) between '-11-27' and '-12-03'group by pmod(datediff(datetime, '1920-01-01') - 3, 7)order by weekday;

小结:晚上21点-22点之间是用户一天中最活跃的时候,凌晨 4 点,则是活跃度最低的时候。一周中,工作日活跃度都差不多,到了周末活跃度有明显提高。

3.4 基于 RFM 模型找出有价值的用户

RFM 模型是衡量客户价值和客户创利能力的重要工具和手段,其中由3个要素构成了数据分析最好的指标,分别是:

R-Recency(最近一次购买时间)F-Frequency(消费频率)M-Money(消费金额)

--R-Recency(最近一次购买时间), R值越高,一般说明用户比较活跃select user_id,datediff('-12-04', max(datetime)) as R,dense_rank() over(order by datediff('-12-04', max(datetime))) as R_rankfrom user_behaviorwhere behavior_type = 'buy'group by user_idlimit 10;--F-Frequency(消费频率), F值越高,说明用户越忠诚select user_id,count(1) as F,dense_rank() over(order by count(1) desc) as F_rankfrom user_behaviorwhere behavior_type = 'buy'group by user_idlimit 10;--M-Money(消费金额),数据集无金额,所以就不分析这一项

对有购买行为的用户按照排名进行分组,共划分为5组,

前 - 1/5 的用户打5分

前 1/5 - 2/5 的用户打4分

前 2/5 - 3/5 的用户打3分

前 3/5 - 4/5 的用户打2分

前 4/5 - 的用户打1分

按照这个规则分别对用户时间间隔排名打分和购买频率排名打分,最后把两个分数合并在一起作为该名用户的最终评分

with cte as(select user_id,datediff('-12-04', max(datetime)) as R,dense_rank() over(order by datediff('-12-04', max(datetime))) as R_rank,count(1) as F,dense_rank() over(order by count(1) desc) as F_rankfrom user_behaviorwhere behavior_type = 'buy'group by user_id)select user_id, R, R_rank, R_score, F, F_rank, F_score, R_score + F_score AS scorefrom(select *,case ntile(5) over(order by R_rank) when 1 then 5when 2 then 4when 3 then 3when 4 then 2when 5 then 1end as R_score,case ntile(5) over(order by F_rank) when 1 then 5when 2 then 4when 3 then 3when 4 then 2when 5 then 1end as F_scorefrom cte) as aorder by score desclimit 20;

小结:可以根据用户的价值得分,进行个性化的营销推荐。

3.5 商品维度的分析

--销量最高的商品select item_id ,sum(case when behavior_type = 'pv' then 1 else 0 end) as pv, --点击数sum(case when behavior_type = 'fav' then 1 else 0 end) as fav, --收藏数sum(case when behavior_type = 'cart' then 1 else 0 end) as cart, --加购物车数sum(case when behavior_type = 'buy' then 1 else 0 end) as buy --购买数from user_behaviorgroup by item_idorder by buy desclimit 10;--销量最高的商品大类select category_id ,sum(case when behavior_type = 'pv' then 1 else 0 end) as pv, --点击数sum(case when behavior_type = 'fav' then 1 else 0 end) as fav, --收藏数sum(case when behavior_type = 'cart' then 1 else 0 end) as cart, --加购物车数sum(case when behavior_type = 'buy' then 1 else 0 end) as buy --购买数from user_behaviorgroup by category_idorder by buy desclimit 10;

小结:缺失商品维表,所以没有太多分析价值。假如有商品维表,可以再展开,以商品纬度进行分析,比如不同行业、不同产品的转化率,还有竞品分析等等。

4 最后

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。