Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
8ab1cc5c
Commit
8ab1cc5c
authored
Feb 27, 2019
by
王志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拆分新老用户重复曝光指标
parent
1f7ce98c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
temp_count.scala
eda/feededa/src/main/scala/com/gmei/temp_count.scala
+23
-23
No files found.
eda/feededa/src/main/scala/com/gmei/temp_count.scala
View file @
8ab1cc5c
...
...
@@ -313,29 +313,29 @@ object Repeated_content_recommendation {
GmeiConfig
.
writeToJDBCTable
(
df1
,
table
=
"Repeated_evaluation_indicator_new"
,
SaveMode
.
Append
)
val
exp_diary_old
=
sc
.
sql
(
s
"""
|select concat_ws('|',de.device_id,de.cid_id)
|from data_feed_exposure de inner join device_id_old
|where de.cid_type = 'diary'
|and de.stat_date ='${stat_date}'
"""
.
stripMargin
)
val
get_result_old
=
exp_diary_old
.
rdd
.
map
((
_
,
1
)).
reduceByKey
(
_
+
_
)
.
sortBy
(
_
.
_2
,
false
)
val
more_than2_old
=
get_result_old
.
filter
(
_
.
_2
>=
2
).
map
(
_
.
_2
).
reduce
((
x
,
y
)
=>
x
+
y
)
println
(
more_than2_old
)
val
all_old
=
get_result_old
.
map
(
_
.
_2
).
reduce
((
x
,
y
)
=>
x
+
y
)
println
(
all_old
)
val
repeated_rate_old
=
more_than2_old
/
all_old
.
toDouble
println
(
repeated_rate_old
)
val
result2
=
List
((
stat_date
,
more_than2_old
,
all_old
))
val
df2
=
sc
.
createDataFrame
(
result2
).
toDF
(
"stat_date"
,
"old_rep_count"
,
"old_imp_all"
)
GmeiConfig
.
writeToJDBCTable
(
df2
,
table
=
"Repeated_evaluation_indicator_old"
,
SaveMode
.
Append
)
//
val exp_diary_old = sc.sql(
//
s"""
//
|select concat_ws('|',de.device_id,de.cid_id)
//
|from data_feed_exposure de inner join device_id_old
//
|where de.cid_type = 'diary'
//
|and de.stat_date ='${stat_date}'
//
""".stripMargin
//
)
//
val get_result_old =exp_diary_old.rdd.map((_, 1)).reduceByKey(_ + _)
//
.sortBy(_._2,false)
//
//
val more_than2_old=get_result_old.filter(_._2 >=2).map(_._2).reduce((x,y)=>x+y)
//
println(more_than2_old)
//
val all_old =get_result_old.map(_._2).reduce((x,y)=>x+y)
//
println(all_old)
//
val repeated_rate_old= more_than2_old / all_old.toDouble
//
println(repeated_rate_old)
//
//
//
val result2=List((stat_date,more_than2_old,all_old))
//
val df2 = sc.createDataFrame(result2).toDF("stat_date","old_rep_count","old_imp_all")
//
//
GmeiConfig.writeToJDBCTable(df2, table = "Repeated_evaluation_indicator_old", SaveMode.Append)
// val temp=get_result.collect()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment