2023年6月23日发(作者:)
电商⽤户画像分析1 项⽬背景1.1 ⽤户画像概念⽤户画像是什么?⽤户画像是真实⽤户的虚拟代表,是建⽴在⼀系列真实数据之上的⽬标⽤户模型,它的本质是⽤户特征的“可视化”,抽象出相应的标签,拟合⽽成的虚拟的形象,主要包含⾃然属性、社会属性、⾏为属性及⼼理属性。需要注意的是,⽤户画像是将⼀类有共同特征的⽤户聚类分析后得出的,因⽽并⾮针对某个具像的特定个⼈。⽤户画像有什么⽤?帮助我们更加⽴体认识⽤户,培养⽤户思维、洞察⽤户的需求,进⽽优化完善产品,提升⽤户体验;帮助我们更加精准进⾏决策,通过市场数据推论到产品的定位⼈群,对市场细分和⽤户分群,做到精细化运营。1.2 项⽬说明本⽂利⽤京东平台真实案例,进⾏实操分析。类似京东这个量级的平台,⽆论从产品类⽬和受众⽤户都是⽐较庞⼤,促使现今电商平台主推千⼈千⾯,我们这⾥针对京东电商平台⼩家电数据进⾏⽤户画像。1.3 提出问题这⾥我们模拟⼀个业务场景,如下:最近平台⼩家电类⽬的产品浏览量、订单数量、搜索数量等都有所下降,运营部门计划对⼩家电类⽬进⾏⼀次季末促销活动,希望你能针对⼩家电消费⽤户特征给出建议?1.4 数据理解1)数据来源京东平台⽤户信息和订单信息(2020年8⽉13⽇-8⽉19⽇)2) 数据字段说明①⽤户信息表共有39个字段,共计325,816条记录。其字段名称对照关系如下:②⽤户订单表共有24个字段,共计9,640,118条记录。其字段名称对照关系如下:2 数据处理2.1 数据导⼊import pandas as pdimport numpy as npimport as pltimport seaborn as sns
# _style('whitegrid')from scipy import stats#
解决matplotlib中⽂乱码from import ms["-serif"] = ["SimHei"]ms["e_minus"] = Falseimport warnings('ignore')user_df = _csv('data/xjd_user_', sep='t', encoding="utf-8", dtype=str)user_cart_df = _csv('data/xjd_user_', sep='t', encoding="utf-8", dtype=str)order_df = _csv('data/xjd_order_', sep='t', encoding="utf-8", dtype=str)2.2 转换特征属性order_df['sale_qtty'] = order_df['sale_qtty'].astype('int')order_df['sale_ord_valid_flag'] = order_df['sale_ord_valid_flag'].astype('int')order_df['cancel_flag'] = order_df['cancel_flag'].astype('int')order_df['self_ord_flag'] = order_df['self_ord_flag'].astype('int')order_df['before_prefr_unit_price'] = order_df['before_prefr_unit_price'].astype('float')order_df['after_prefr_unit_price'] = order_df['after_prefr_unit_price'].astype('float')order_df['user_actual_pay_amount'] = order_df['user_actual_pay_amount'].astype('float')order_df['total_offer_amount'] = order_df['total_offer_amount'].astype('float')order_[:,'check_account_tm '] = _datetime(order_[:,'check_account_tm'])order_[:,'sale_ord_tm'] = _datetime(order_[:,'sale_ord_tm'])order_[:,'sale_ord_dt'] = _datetime(order_[:,'sale_ord_dt'])2.3 重复值处理#查看是否有重复值,⽅便后续连接两表user_df['user_log_acct'].nunique()2.4 数据⼀致化#
将订单表和⽤户信息表合并order_user_df = (order_df, user_df, on='user_log_acct')#
发现有重复值,在做⽤户属性的时候不需要有重复值,所以去除重复⽤户ID。#
去除重复值,保留重复数据的第⼀个user_info_df = order_user__duplicates(subset=['user_log_acct'], keep='first')
3 问题分析这是⼀个⾮常典型的对⽤户画像进⾏构建和分析的需求,需求要求我们能够对促销活动进⾏⼀些建议,⼀场促销活动必然包含以下⼏个部分:● 促销活动的受众 -> ⽤户的基本属性● 促销活动的时间 -> ⽤户的购物⾏为属性● 促销活动的产品 -> ⽤户的偏好属性我们可以从这些⾓度去勾勒出⼩家电消费群体的⽤户画像,从⽽可以进⼀步从⽤户特征本⾝来为促销活动提供建议和指导因此根据业务问题,将其拆解为以下三个具体维度来分析:⽤户基本属性⽤户购买⾏为属性⽤户商品偏好3.1 ⽤户基本属性基本属性包括⾃然属性和社会属性。⾃然属性:性别、年龄、地域等;社会属性:婚育状况、学历、职业等。3.1.1 ⽤户性别分布数据表中不存在完全重复的数据,在性别字段上,共有三个值,分别是1,0,和-1,其中1代表男性,0代表⼥性,⽽-1则代表未识别。user_sex_df = user_info_y('ulp_base_sex', as_index=False)['user_log_acct']. agg({'ulp_base_sex_count':'count'})#
⼥性⽤户female_user = user_sex_df['ulp_base_sex_count'][1]
#
男性⽤户male_user = user_sex_df['ulp_base_sex_count'][2]
labels = ['男','⼥']Y = [male_user, female_user]fig = (figsize=(7,7))pathches,l_text,p_text = (Y, labels=labels,
autopct='%1.0f%%',
startangle=90, colors=['#6699cc','#cc6699'])
("平台⽤户的性别分布",size=24)for i in p_text: #
设置饼图内部的⽂字 _size(16) _color('w')
for i in l_text: # #
设置饼图外部的⽂字 _size(16) _color('r')
()
分析:从数据来看,⼩家电消费⽤户男性居多,占⽐约55%,但与⼥性⽤户数量差别不是特别⼤(10%)3.1.2 ⽤户年龄分布表中⽤户年龄⽤数字指代,其中[1,2,3,4,5,6]分别代表[‘18岁以下’, ‘18~25岁’, ‘25~35岁’, ‘35~45岁’, ‘45~55岁’,‘55岁以上’],⽽-1则代表未识别。user_age_df = user_info_y('ulp_base_age', as_index=False)['user_log_acct'] .agg({'user_age_count':'count'})#
类型转换&异常值处理user_age_df['ulp_base_age'] = user_age_df['ulp_base_age'].astype('int')user_age_df = user_age_df[user_age_df['ulp_base_age'] > 0]x = ['18岁以下', '18~25岁', '25~35岁', '35~45岁', '45~55岁', '55岁以上']y = user_age_df['user_age_count'](figsize=(20,8),dpi=80)('ggplot')("⼩家电消费⽤户的年龄分布", size=24) #
图标题(size=16) # x轴字体⼤⼩调整(size=16) # y轴字体⼤⼩调整(x, y, width=0.3, color='#6699CC')# t(x, y, palette="Greens_r")for i in range(len(x)): (i,x[i]+3000,'%d'%x[i],ha='center',va='center')()分析:⽤户多集中在25-35岁的年龄区间 ,25岁以下的年轻⽤户和45岁以上的中⽼年⽤户⽐较少。3.1.3 ⽤户地域分布#
⽤户省份分布user_region_df = user_info_y('ulp_addr_province', as_index=False)['user_log_acct']. agg({'region_count':'count'})user_region_s = ['province_name','region_count']user_region_df = user_region__values(by='region_count', ascending=False)#
去除异常值user_region_df = user_region_df[user_region_df['province_name'] != '-1']x = user_region_df['province_name'][::-1]
y = user_region_df['region_count'][::-1]
(figsize=(20,13), dpi=80)("⼩家电消费⽤户的地域分布", size=24) #
图标题('region_count',size=16)('province_name',size=16)(size=16) # x轴字体⼤⼩调整(size=16) # y轴字体⼤⼩调整(x, y, height=0.8, color='#6699CC')(xmax=60000)for i in range(len(x)): (x[i]+2000,i,'%d' %x[i],ha='center',va='center',size=12)()#
所在城市分布user_city_df = user_info_y('ulp_addr_city', as_index=False)['user_log_acct'] .agg({'city_count':'count'}) .sort_values(by='city_count', ascending=False)#
取前⼗个城市user_city_df = user_city_df[:10]x = user_city_df['ulp_addr_city'][::-1]y = user_city_df['city_count'][::-1](figsize=(20,8),dpi=80)("⼩家电消费⽤户的城市分布", size=24) #
图标题(size=16) # x轴字体⼤⼩调整(size=16) # y轴字体⼤⼩调整 # height是⽔平条形图宽度(x, y, align='center', height=0.6, color='#6699CC')()分析:⼩家电类⽬的消费者来⾃⼴东的最多,其次是江苏和北京。排名前五的地区均为东部沿海地区。在城市分布⽅⾯,北上⼴深 四个超⼀线城市占据消费⽤户数量的前四名。3.1.4 ⽤户受教育⽔平⽤户受教育⽔平[1,2,3,4]代表的是[‘初中及以下’, ‘⾼中(中专)’, ‘⼤学(专科及本科)’, ‘研究⽣(硕⼠及以上’],-1代表⽤户教育⽔平未被识别user_edu_df = user_info_y('ulp_base_education', as_index=False)['user_log_acct'] .agg({'edu':'count'}) .sort_values(by='ulp_base_education', ascending=True)user_edu_df = user_edu_df[user_edu_df['ulp_base_education'] != '-1']x = ['初中及以下', '⾼中(中专)', '⼤学(专科及本科)', '研究⽣(硕⼠及以上']y = user_edu_df['edu'](figsize=(20,8),dpi=80)('ggplot')("⽤户的学历分布", size=24)(size=16) # x轴字体⼤⼩调整(size=16) # y轴字体⼤⼩调整(x, y, width=0.3, color='#6699CC')# t(x, y, palette="Oranges_r")() 分析:绝⼤多数⼩家电消费⽤户拥有⼤学及以上学历,说明该类⽬的消费者学历⽔平⽐较⾼3.1.5 ⽤户职业分布⽤户职业[a,b,c,d,e,f,g,h]代表的是[‘⾦融从业者’, ‘医务⼈员’, ‘公务员/事业单位’, ‘⽩领/⼀般职员’, ‘⼯⼈/服务业⼈员’, ‘教师’, ‘互联⽹从业⼈员’, ‘学⽣’],-1代表⽤户职业未被识别。user_profession_df = user_info_y('ulp_base_profession', as_index=False)['user_log_acct'] .agg({'profession':'count'}) .sort_values(by='ulp_base_profession', ascending=True)user_profession_df = user_profession_df[user_profession_df['ulp_base_profession'] != '-1']x = ['⾦融从业者', '医务⼈员', '公务员/事业单位', '⽩领/⼀般职员', '⼯⼈/服务业⼈员', '教师', '互联⽹从业⼈员', '学⽣']y = user_profession_df['count'](figsize=(20,8),dpi=80)('ggplot')(ymax=50000) # y轴坐标最⼤值设为("⽤户的职业分布", size=24)(size=16) # x轴字体⼤⼩调整(size=16) # y轴字体⼤⼩调整# (x, y, width=0.5, color='#6699CC')t(x, y)() 分析:职业⼀般以互联⽹⾏业或者其他⾏业的⽩领职业为主。3.1.6 ⽤户婚育情况⽤户婚育状况中[0,1]代表的是[‘未婚’, ‘已婚’],-1代表⽤户婚育状况未被识别。user_marriage_df = user_info_y('ulp_base_marriage', as_index=False)['user_log_acct'] .agg({'marriage':'count'}) .sort_values(by='marriage', ascending=False)married_user = user_marriage_df['marriage'].iloc[0] #
取第0⾏unmarried_user = user_marriage_df['marriage'].iloc[1] #
取第1⾏labels = ['已婚', '未婚']Y = [married_user, unmarried_user]fig = (figsize=(7,7))pathches,l_text,p_text = (Y, labels=labels,
autopct='%1.1f%%',
startangle=90, colors=['#6699cc','#cc6699']) # startangle是图旋转⾓度("⽤户的婚姻情况")for i in p_text: #
设置饼图内部的⽂字 _size(16) _color('w')
for i in l_text: # #
设置饼图外部的⽂字 _size(16) _color('r')
() 分析:已婚的⽤户占59.51%,未婚的⽤户占40.49%,已婚⽤户⾼于未婚⽤户的数量,但未婚⼈群也需要重视。3.1.7 ⽤户有孩可能性user_child_df = user_info_y('ulp_base_child', as_index=False)['user_log_acct'] .agg({'child':'count'}) .sort_values(by='child', ascending=False)
#
剔除未能识别的数据
user_child_df = user_child_df[user_child_df['ulp_base_child'] != '-1']very_high = user_child_df['child'].iloc[1] #
⾼,取第1⾏high = user_child_df['child'].iloc[0] #
较⾼,取第0⾏low = user_child_df['child'].iloc[2] #
较低,取第2⾏very_low = user_child_df['child'].iloc[3] #
低,取第3⾏labels = ['⾼', '较⾼', '较低', '低']Y = [very_high, high, low, very_low]fig = (figsize=(7,7))colors = ['tomato','lightskyblue','goldenrod','green']explode = [0.1,0,0,0]pathches,l_text,p_text = (Y, labels=labels,
autopct='%1.1f%%',
startangle=90. colors=colors, explode=explode) # startangle是图旋转⾓度("⽤户的有孩可能性分布")(loc='best',fontsize=12)for i in p_text: #
设置饼图内部的⽂字 _size(16) _color('w')
for i in l_text: # #
设置饼图外部的⽂字 _size(16) _color('r')
() 分析:⽤户有孩的概率处于“较⾼”或“⾼”层级的⼈数约占56%,⽽处于“较低”和“低”层级上的⼈数约占44%,相⽐较来看,⽤户中有孩的可能性稍⾼⼀些。总结: 从⽤户基本属性看出,⼩家电消费⽤户多为来⾃⼀线城市的男性,年龄在30岁左右,已婚已育,⾼学历,⼤部分从事互联⽹或其他⽩领⾏业。3.2 ⽤户购买⾏为属性在订单数据中,每⼀条记录代表着⼀个订单下单个商品的购买情况,也就是说,同⼀个订单中购买的多个商品是按照商品种类分割成多条记录的,在观察⽤户购买商品的品类分布时,应该以订单为⼀个观察单位。3.2.1 ⽤户购买商品类⽬分布选取有效订单(订单有效条件为:订单有效标志=1,订单取消标志=0,⽀付时间!=空值,优惠后单价>0)#
订单维度的分析,
使⽤的是有效订单vaild_order_user_df = order_user_df[(order_user_df['sale_ord_valid_flag'] == 1) &(order_user_df['cancel_flag'] == 0) &(order_user_df['check_account_tm'] != 0) &(order_user_df['before_prefr_unit_price'] != 0) &(order_user_df['user_actual_pay_amount'] != 0)] #
筛选有效订单
user_order_cate_df = vaild_order_user_y('item_third_cate_name', as_index=False)['sale_ord_id'] .agg({'cate_count':'count'}) .sort_values(by='cate_count', ascending=False)x = user_order_cate_df['item_third_cate_name']y = user_order_cate_df['cate_count'](figsize=(20,15),dpi=80)('订单数量', size=20)#(x, y, align='center', color='#6699CC')("⼩家电消费⽤户的细分品类订单量", size=24)(size=16) # x轴字体⼤⼩调整(size=16) # y轴字体⼤⼩调整t(y, x)()分析:从订单数据上来看,电风扇是最受欢迎的品类。但是这个订单数据是⼋⽉中旬的数据,那时正值天⽓炎热,所以电风扇需求量⽐较⼤,为季节性产品。如果促销活动是在夏天快要结束或者夏天结束之后进⾏,那应该选择第⼆受欢迎的 净⽔器、饮⽔机和加湿器等类⽬。3.2.2 ⽤户订单数量的⽇期分布#
要按星期统计,所以要把时间按照星期⼏分组#
先把时间变星期,再按星期分组vaild_order_user_df_2 = vaild_order_user_()#
将订单⽇期转化为星期,数字0—6,依次代表周⽇、周⼀、周⼆、周三、周四、周五、周六vaild_order_user_df_2['order_time_week'] = vaild_order_user_df_2['sale_ord_tm'].apply(lambda x: me('%w'))user_order_week_df = vaild_order_user_df_y('order_time_week', as_index=False)['sale_ord_id']. agg({'week_count':'count'}).sort_values(by='order_time_week', ascending=True)user_order_week_df[0:1] # 0是周⽇user_order_week_df[1:] # 1-6是周⼀到周六#
两个dataframe上下拼接,也就是把后⾯的dataframe,追加到前⾯dataframe的末尾user_order_week_df_2 = user_order_week_df[1:].append(user_order_week_df[0:1])user_order_week_df_2x = ['星期⼀', '星期⼆', '星期三', '星期四', '星期五', '星期六', '星期⽇']y = user_order_week_df_2['week_count'](figsize=(20,8),dpi=80)('ggplot')(ymin=0,ymax=80000) # y轴坐标,最⼩值0.最⼤值设为("⼩家电消费⽤户订单数量的⽇期分布", size=24)(size=16) # x轴字体⼤⼩调整(size=16) # y轴字体⼤⼩调整(x, y, linewidth=2.0, color='#6699CC', linestyle='-')()
分析:从整周的数据上来看,绝⼤部分订单都是在周⼆和周六完成的,⽽周三的订单量最少3.2.3 ⽤户订单数量的时间分布#
把订单时间只保留⼩时vaild_order_user_df_2['order_time_hms'] = vaild_order_user_df_2['sale_ord_tm'] .apply(lambda x: me('%H:00:00'))user_order_hms_df = vaild_order_user_df_y('order_time_hms', as_index=False)['sale_ord_id']. agg({'hms_count':'count'}).sort_values(by='order_time_hms', ascending=True)#
⽣成时间标签hour_list = [x for x in range(0, 24)]x = hour_listy = user_order_hms_df['hms_count'](figsize=(20,8),dpi=80)('ggplot')(ymin=0,ymax=20000) # y轴坐标,最⼩值0.最⼤值设为("⼩家电消费⽤户订单数量的时间分布", size=24)(x, size=16) # x轴显⽰内容及字体⼤⼩调整(size=16) # y轴字体⼤⼩调整(x, y, linewidth=2.0, color='#6699CC', linestyle='-', clip_on=False)()
分析:从单⽇的每⼩时订单量来 看,早上10点-11点,晚上20点-22点是⽤户⼤量下单的时间。因此建议在周⼆和周六的早⼗点和晚⼋点各推送⼀ 次促销的活动。3.2.4 ⽤户的促销敏感度#
按⽤户维度统计的量,
取全部⽤户的数据cfv_sens_prom_df = user_info_y('cfv_sens_promotion', as_index=False)['user_log_acct'] .agg({'cfv_sens_promotion_count':'count'}) .sort_values(by='cfv_sens_promotion_count', ascending=False)user_info_df_2 = user_info_()user_info_df_2 = user_info_df_2[user_info_df_2['cfv_sens_promotion'] != '-1']cfv_sens_prom_df_2 = user_info_df_y('cfv_sens_promotion', as_index=False)['user_log_acct'] .agg({'cfv_sens_promotion_count':'count'}) .sort_values(by='cfv_sens_promotion_count', ascending=False)user_info_df_2['sens_promotion'] = user_info_df_2['cfv_sens_promotion'] .apply(lambda x: x[-1]) #
只保留最后⼀位字符user_order_sens_promotion_df = user_info_df_y('sens_promotion', as_index=False)['user_log_acct'] .agg({'sens_promotion_count':'count'}) .sort_values(by='sens_promotion', ascending=True)x = ['不敏感', '轻度敏感', '中度敏感', '⾼度敏感', '极度敏感']y = user_order_sens_promotion_df['sens_promotion_count'](figsize=(20,8),dpi=80)('ggplot')("⽤户的促销敏感度分布", size=24)(size=16) # x轴字体⼤⼩调整(size=16) # y轴字体⼤⼩调整# (x, y, width=0.5, color='#6699CC')t(x,y)()
分析:根据历史数据,绝⼤部分的⼩家电消费⽤户对促销⾼度敏感,但是仅有⼀⼩部分对促销活动是极度敏感的。这说明针对⼩家电消费⽤户的促销活动应当确定合适的促销⼒度,并在促销活动的形式上多 功夫。3.2.5 ⽤户的评论敏感度cfv_sens_comment_df = user_info_y('cfv_sens_comment', as_index=False)['user_log_acct'] .agg({'cfv_sens_comment_count':'count'}) .sort_values(by='cfv_sens_comment_count', ascending=False)user_info_df_3 = user_info_()user_info_df_3 = user_info_df[user_info_df['cfv_sens_comment'] != '-1']cfv_sens_comment_df_2 = user_info_df_y('cfv_sens_comment', as_index=False)['user_log_acct'] .agg({'cfv_sens_comment_count':'count'}) .sort_values(by='cfv_sens_comment_count', ascending=False)user_info_df_3['sens_comment'] = user_info_df_3['cfv_sens_comment'] .apply(lambda x: x[-1]) #
只保留最后⼀位字符user_order_sens_comment_df = user_info_df_y('sens_comment', as_index=False)['user_log_acct'] .agg({'sens_comment_count':'count'}) .sort_values(by='sens_comment', ascending=True)
x = ['不敏感', '轻度敏感', '中度敏感', '⾼度敏感', '极度敏感']y = user_order_sens_comment_df['sens_comment_count'](figsize=(20,8),dpi=80)('ggplot')("⼩家电消费⽤户的评论敏感度分布", size=24)(size=16) # x轴字体⼤⼩调整(size=16) # y轴字体⼤⼩调整# (x, y, width=0.5, color='#6699CC')t(x,y)()
分析:绝⼤部分的⼩家电消费⽤户对产品的评论极度敏感。 这说明⼩家电消费⽤户⾮常看重产品的⼝碑和使⽤反馈,在促销选品上可以选择评价⾼、评论数多的产品;在活动⽂案上可以多体现促销产品的⼝碑。3.3 ⽤户的整体性画像描述- 消费⽤户的特征多数为来⾃⼀线城市的男性,年龄在30左右,已婚,有孩,学历⽔平较⾼,从事互联⽹、教师等⾼收⼊⾏业。 他们喜欢在周⼆和周六的早上10点左右和晚上10点左右下单。他们关注产品的促销活动,喜欢追求有⽣活 品味,有良好的⼝碑的产品。他们关⼼家庭,但是因为⽣活节奏和⼯作压⼒却⼜没有时间在家庭⽣活上付出 很多时间和精⼒。前两周他们最常购买的⼩家电是电风扇。4 总结及建议我们通过多个维度对⼩家电⽤户特征进⾏分析,对此群体⽤户有了⼀个⽴体的认知,如下:4.1 画像总结4.2 促销活动建议:现已知⽤户的基本特征,结合⽂章第⼀部分对业务需求的拆解和分析思路,我们对此次促销活动给出如下建议:注:因为此⽤户和订单数据集只有7天的数据(2020年8⽉13⽇-2020年8⽉19⽇),刻画的⽤户画像可能存在偏差。
发布者:admin,转转请注明出处:http://www.yc00.com/news/1687518416a16442.html
评论列表(0条)