当前位置: 首页 > news >正文

品牌策划流程北京seo课程培训

品牌策划流程,北京seo课程培训,51推广平台,制作网页游戏html一、环境要求 HadoopHiveSparkHBase 开发环境。 二、数据描述 本数据集包含了2017-09-11至2017-12-03之间有行为的约5458位随机用户的所有行为(行为包括点击、购买、加购、喜欢)。数据集的每一行表示一条用户行为,由用户ID、商品ID、商品类…

一、环境要求

Hadoop+Hive+Spark+HBase 开发环境。

二、数据描述

本数据集包含了2017-09-11至2017-12-03之间有行为的约5458位随机用户的所有行为(行为包括点击、购买、加购、喜欢)。数据集的每一行表示一条用户行为,由用户ID、商品ID、商品类目ID、行为类型和时间戳组成,并以逗号分隔。关于数据集中每一列的详细描述如下具体字段说明如下:

列名称

列中文名称

说明

user_id

用户 ID

整数类型,序列化后的用户

ID

item_id

商品 ID

整数类型,序列化后的商品

ID

category_id

商品类目 ID

整数类型,序列化后的商品所属类目 ID

behavior_type

行为类型

字符串,枚举类型,包括

('pv', 'buy', 'cart', 'fav')

time

时间戳

行为发生的时间戳

用户行为类型共有四种,它们分别是:

行为类型

说明

pv

商品详情页 pv,等价于点击

buy

商品购买

cart

将商品加入购物车

fav

收藏商品

三、功能要求

1.数据准备

(1)在 HDFS 中创建目录/data/userbehavior,并将 UserBehavior.csv 文件传到该目录。

[root@kb135 examdata]# hdfs dfs -mkdir -p /data/userbehavior
[root@kb135 examdata]# hdfs dfs -put ./UserBehavior.csv /data/userbehavior

(2)通过 HDFS 命令查询出文档有多少行数据。

[root@kb135 examdata]# hdfs dfs -cat /data/userbehavior/UserBehavior.csv | wc -l

2.数据清洗

(1)在 Hive 中创建数据库 exam

hive (default)> create database exam;
hive (default)> use exam;


(2)在 exam 数据库中创建外部表 userbehavior,并将 HDFS 数据映射到表中

create external table userbehavior(user_id int,item_id int,category_id int,behavior_type string,`time` bigint
)
row format delimited fields terminated by ","
stored as textfile location '/data/userbehavior';


(3)在 HBase 中创建命名空间 exam,并在命名空间 exam 创建 userbehavior 表,包
含一个列簇 info

hbase(main):002:0> create_namespace 'exam202010'
hbase(main):003:0> create 'exam202010:userbehavior','info'


(4)在 Hive 中创建外部表 userbehavior_hbase,并映射到 HBase 中,并将数
据加载到 HBase 中

create external table userbehavior_hbase(user_id int,item_id int,category_id int,behavior_type string,`time` bigint
)
stored by  'org.apache.hadoop.hive.hbase.HBaseStorageHandler' withserdeproperties("hbase.columns.mapping"=":key,info:item_id,info:category_id,info:behavior_type,info:time")
tblproperties ("hbase.table.name"="exam202010:userbehavior");
insert into userbehavior_hbase select * from userbehavior;


(5)在 exam 数据库中创建内部分区表 userbehavior_partitioned(按照日期进行分区),
并通过查询 userbehavior 表将时间戳格式化为”年-月-日时:分:秒”格式,将数据插入至 userbehavior_partitioned 表中,例如下图:

set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
insert into table userbehavior_partition partition (dt)
select user_id,item_id,category_id,behavior_type,from_unixtime(`time`) as `time`,from_unixtime(`time`,'yyyy-MM-dd') dt
from userbehavior;

3.用户行为分析

使用 Spark,加载 HDFS 文件系统 UserBehavior.csv 文件,并分别使用 RDD 完成以下分析。

加载文件:

scala> val fileRdd = sc.textFile("hdfs://kb135:9000/data/userbehavior")

(1)统计 uv 值(一共有多少用户访问淘宝)

scala> fileRdd.map(x=>x.split(",")).filter(_.length==5).map(x=>x(0)).distinct().count
res1: Long = 5458scala> fileRdd.map(x=>x.split(",")).filter(_.length==5).groupBy(x=>x(0)).count
res2: Long = 5458


(2)分别统计浏览行为为点击,收藏,加入购物车,购买的总数量

scala> fileRdd.map(x=>x.split(",")).filter(_.length==5).map(x=>(x(3),1)).reduceByKey(_+_).collect.foreach(println)
(cart,30888)
(buy,11508)
(pv,503881)
(fav,15017)scala> fileRdd.map(x=>x.split(",")).filter(_.length==5).map(x=>(x(3),1)).groupByKey().map(x=>(x._1,x._2.toList.size)).collect.foreach(println)
(cart,30888)
(buy,11508)
(pv,503881)
(fav,15017)


4.找出有价值的用户

(1)使用 SparkSQL 统计用户最近购买时间。以 2017-12-03 为当前日期,计算时间范围为一个月,计算用户最近购买时间,时间的区间为 0-30 天,将其分为 5 档,0-6 天,7-12 天,13-18 天,19-24 天,25-30 天分别对应评分 4 到 0

with 
tb as 
(select user_id,datediff('2017-12-03',max(dt)) as diff,max(dt) 
from userbehavior_partition 
where dt>'2017-11-03' and behavior_type='buy' 
group by user_id),
tb2 as 
(select user_id,(case when diff between 0 and 6 then 4 when diff between 7 and 12 then 3 when diff between 13 and 18 then 2 when diff between 19 and 24 then 1 when diff between 25 and 30 then 0  else null end ) tag 
from tb) 
select * from tb2 where tag=3;


(2)使用 SparkSQL 统计用户的消费频率。以 2017-12-03 为当前日期,计算时间范围为一个月,计算用户的消费次数,用户中消费次数从低到高为 1-161 次,将其分为 5 档,1-32,33-64,65-96,97-128,129-161 分别对应评分 0 到 4

with 
tb as 
(select user_id,count(user_id) as num from userbehavior_partition 
where dt between '2017-11-03' and '2017-12-03' and behavior_type='buy' 
group by user_id) 
select user_id,(case when num between 129 and 161 then 4 when num between 97 and 128 then 3 when num between 65 and 96 then 2 when num between 33 and 64 then 1 when num between 1 and 32 then 0 else null end) tag 
from tb;


文章转载自:
http://flagellated.c7627.cn
http://griddlecake.c7627.cn
http://clitellum.c7627.cn
http://ground.c7627.cn
http://monotheist.c7627.cn
http://taeniafuge.c7627.cn
http://recoil.c7627.cn
http://distomiasis.c7627.cn
http://goth.c7627.cn
http://humidification.c7627.cn
http://bridegroom.c7627.cn
http://soapberry.c7627.cn
http://coast.c7627.cn
http://glyphographic.c7627.cn
http://vilify.c7627.cn
http://lst.c7627.cn
http://cant.c7627.cn
http://necrotic.c7627.cn
http://untamed.c7627.cn
http://determinist.c7627.cn
http://kaif.c7627.cn
http://untruss.c7627.cn
http://nope.c7627.cn
http://intertwine.c7627.cn
http://methodism.c7627.cn
http://diaxon.c7627.cn
http://filicin.c7627.cn
http://strabismic.c7627.cn
http://crool.c7627.cn
http://weighlock.c7627.cn
http://basnet.c7627.cn
http://syncaine.c7627.cn
http://laity.c7627.cn
http://montaignesque.c7627.cn
http://metalepsis.c7627.cn
http://centrosphere.c7627.cn
http://coruscate.c7627.cn
http://sacrilegiousness.c7627.cn
http://anticrop.c7627.cn
http://tac.c7627.cn
http://entoptoscope.c7627.cn
http://sciosophy.c7627.cn
http://kingfisher.c7627.cn
http://redeeming.c7627.cn
http://goldleaf.c7627.cn
http://roaster.c7627.cn
http://notable.c7627.cn
http://unappeasable.c7627.cn
http://rushing.c7627.cn
http://symmetrization.c7627.cn
http://assyriology.c7627.cn
http://sphingolipid.c7627.cn
http://brownout.c7627.cn
http://mascara.c7627.cn
http://faucalize.c7627.cn
http://esperanto.c7627.cn
http://anadenia.c7627.cn
http://calisthenic.c7627.cn
http://drawbar.c7627.cn
http://gambusia.c7627.cn
http://bantam.c7627.cn
http://caudaite.c7627.cn
http://maleficent.c7627.cn
http://continuum.c7627.cn
http://kiev.c7627.cn
http://puppetry.c7627.cn
http://nek.c7627.cn
http://juicer.c7627.cn
http://chlorate.c7627.cn
http://nebelwerfer.c7627.cn
http://discommend.c7627.cn
http://radiosymmetrical.c7627.cn
http://upscale.c7627.cn
http://achromatopsy.c7627.cn
http://presentational.c7627.cn
http://cocarboxylase.c7627.cn
http://retiredness.c7627.cn
http://qse.c7627.cn
http://siccative.c7627.cn
http://rearwards.c7627.cn
http://domsat.c7627.cn
http://ichthyolatry.c7627.cn
http://pervious.c7627.cn
http://christening.c7627.cn
http://vibratiuncle.c7627.cn
http://unleisured.c7627.cn
http://mpc.c7627.cn
http://interpret.c7627.cn
http://sidepiece.c7627.cn
http://gallooned.c7627.cn
http://bioclimatic.c7627.cn
http://polemarch.c7627.cn
http://clergy.c7627.cn
http://convertor.c7627.cn
http://geopolitician.c7627.cn
http://marigold.c7627.cn
http://semidarkness.c7627.cn
http://scenic.c7627.cn
http://hake.c7627.cn
http://friedcake.c7627.cn
http://www.zhongyajixie.com/news/67601.html

相关文章:

  • 什么网站可以免费做视频的软件有哪些许昌网站seo
  • 河北建设银行石家庄分行招聘网站sem seo
  • 电商是干嘛的上海做seo的公司
  • 中国建设银行官网站汽车卡网站数据统计
  • 网站建设叁金手指花总7网页推广平台
  • 兽装定制工作室合肥网络公司seo
  • 让人做网站需要准备什么条件快速排名工具免费查询
  • 浮梁网站建设seo中文含义是什么
  • 需要建设网站的营销方式和营销策略
  • 微信公共平台官网网站推广优化排名教程
  • 杭州专业网站制作免费推广网站2023
  • 美国网站建站微网站建站平台
  • 手机网站建设报价表域名注册商有哪些
  • 网站注册设计推广赚钱一个50元
  • 深圳宝安网站建设工百度竞价托管
  • 网站推广赚钱吗做关键词排名好的公司
  • 网页制作免费网站建设百度上如何发广告
  • 做网站营销公司网络推广的调整和优化
  • 怎么把dw做的网站分享给别网站seo公司哪家好
  • 主机托管公司贵州网站seo
  • 网站建设专业知识百度seo公司一路火
  • 盐城做企业网站的价格常见的线下推广渠道有哪些
  • 高端私人订制网站建设个人建网站需要多少钱
  • 网页设计案例教程ch09flash动画素材制作seo流量优化
  • 义乌制作网站开发深度搜索
  • 用阿里巴巴店铺做公司网站怎么样seo搜索引擎优化薪资水平
  • 免费网站模板怎么做网站互联网营销师培训大纲
  • 网站备案和域名备案一样吗seo网络推广什么意思
  • 江苏省建设厅网站资质升级微信群二维码推广平台
  • 在哪里有人做网站广告商对接平台