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
caacb65f
Commit
caacb65f
authored
Jan 10, 2019
by
王志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复bug
parent
73217b30
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
103 deletions
+0
-103
strategy_other.scala
eda/feededa/src/main/scala/com/gmei/strategy_other.scala
+0
-103
No files found.
eda/feededa/src/main/scala/com/gmei/strategy_other.scala
View file @
caacb65f
...
...
@@ -718,107 +718,4 @@ object Recommendation_stra233tegy_all {
}
//以下内容统计信息熵基尼系数
object
Gini_coefficient
{
Logger
.
getLogger
(
"org.apache.spark"
).
setLevel
(
Level
.
WARN
)
Logger
.
getLogger
(
"org.apache.eclipse.jetty.server"
).
setLevel
(
Level
.
OFF
)
case
class
Params
(
env
:
String
=
"dev"
,
date
:
String
=
"2018-08-01"
)
extends
AbstractParams
[
Params
]
with
Serializable
val
defaultParams
=
Params
()
val
parser
=
new
OptionParser
[
Params
](
"Feed_EDA"
)
{
head
(
"Gini_coefficient"
)
opt
[
String
](
"env"
)
.
text
(
s
"the databases environment you used"
)
.
action
((
x
,
c
)
=>
c
.
copy
(
env
=
x
))
opt
[
String
]
(
"date"
)
.
text
(
s
"the date you used"
)
.
action
((
x
,
c
)
=>
c
.
copy
(
date
=
x
))
note
(
"""
|For example, the following command runs this app on a tidb dataset:
|
| spark-submit --class com.gmei.WeafareStat ./target/scala-2.11/feededa-assembly-0.1.jar \
"""
.
stripMargin
+
s
"| --env ${defaultParams.env}"
)
}
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
parser
.
parse
(
args
,
defaultParams
).
map
{
param
=>
GmeiConfig
.
setup
(
param
.
env
)
val
spark_env
=
GmeiConfig
.
getSparkSession
()
val
sc
=
spark_env
.
_2
val
ti
=
new
TiContext
(
sc
)
ti
.
tidbMapTable
(
dbName
=
"eagle"
,
tableName
=
"src_mimas_prod_api_diary"
)
ti
.
tidbMapTable
(
dbName
=
"jerry_prod"
,
tableName
=
"data_feed_click"
)
ti
.
tidbMapTable
(
dbName
=
"jerry_prod"
,
tableName
=
"blacklist"
)
ti
.
tidbMapTable
(
dbName
=
"jerry_prod"
,
tableName
=
"data_feed_exposure"
)
import
sc.implicits._
val
stat_date
=
GmeiConfig
.
getMinusNDate
(
1
)
//println(param.date)
val
partition_date
=
stat_date
.
replace
(
"-"
,
""
)
//获取3.5星及以上日记本id
val
diary_id
=
sc
.
sql
(
s
"""
|select id as diary_id
|from src_mimas_prod_api_diary
|where content_level >=3.5
|and doctor_id is not null
"""
.
stripMargin
)
diary_id
.
createOrReplaceTempView
(
"temp1"
)
//机构id
val
agency_id
=
sc
.
sql
(
s
"""
|SELECT DISTINCT(cl_id) as device_id
|FROM online.ml_hospital_spam_pv_day
|WHERE partition_date >= '20180402'
|AND partition_date <= '20181203'
|AND pv_ratio >= 0.95
|UNION ALL
|SELECT DISTINCT(cl_id) as device_id
|FROM online.ml_hospital_spam_pv_month
|WHERE partition_date >= '20171101'
|AND partition_date <= '20181203'
|AND pv_ratio >= 0.95
"""
.
stripMargin
)
agency_id
.
createOrReplaceTempView
(
"agency_id"
)
//统计次数
val
diary_clk_num
=
sc
.
sql
(
s
"""
|select temp1.diary_id as diary_id,count(ov.cl_id) as diary_clk_num
|from online.tl_hdfs_maidian_view ov left join temp1
|on params["business_id"]= temp1.diary_id
|where ov.action="page_view"
|and ov.params["page_name"]="diary_detail"
|and temp1.diary_id is not null
|and (ov.params["out"]-ov.params["in"])<7200
|and ov.partition_date ='${partition_date}'
|and ov.cl_id not in (select device_id from blacklist)
|group by temp1.diary_id
"""
.
stripMargin
)
GmeiConfig
.
writeToJDBCTable
(
diary_clk_num
,
"Gini_coefficient"
,
SaveMode
.
Overwrite
)
}
}
}
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