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
64fa9ca5
Commit
64fa9ca5
authored
Aug 13, 2018
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getTopFeatures.py/get_result reduce args
parent
5f2f7a0b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
29 deletions
+12
-29
getTopFeatures.py
eda/test/getTopFeatures.py
+12
-29
No files found.
eda/test/getTopFeatures.py
View file @
64fa9ca5
...
...
@@ -42,7 +42,7 @@ class TopFeatures(object):
imp_times
=
tuple2dict
(
con_sql
(
sql
))
return
imp_times
def
get_result
(
self
,
platform
,
clk
=
{},
imp
=
{},
clk
_n
=
2
,
result_types
=
"ctr"
):
def
get_result
(
self
,
platform
,
clk_n
=
2
,
result_types
=
"ctr"
):
"""
platform : "所有";"苹果","安卓" #方便显示
cid_type : 'diary';'answer';'question';"everything"... #方便显示
...
...
@@ -52,6 +52,8 @@ class TopFeatures(object):
result_types : sorted by ["clk","imp","ctr"]
rtype : list
"""
clk
=
self
.
get_click_times
()
imp
=
self
.
get_impression_times
()
topn
=
[]
#获取topN的点击
if
imp
==
{}
or
result_types
==
"clk"
:
...
...
@@ -87,7 +89,6 @@ class TopFeatures(object):
def
result2file
(
self
,
result_lst
,
fpath
):
"""
cid_type : 'diary';'answer';'question';"everything"... #方便显示
result_lst : [all_result,ios_result,android_result]
fpath : output filename
rtype : none
...
...
@@ -115,19 +116,13 @@ def main():
#1. Top diary
top_diary_all
=
TopFeatures
(
"all"
,
"diary"
,
100
)
clk_diary_times_all
=
top_diary_all
.
get_click_times
()
imp_diary_times_all
=
top_diary_all
.
get_impression_times
()
clk_diary_ctr_all
=
top_diary_all
.
get_result
(
"所有"
,
clk_diary_times_all
,
imp_diary_times_all
,
4
,
"ctr"
)
clk_diary_ctr_all
=
top_diary_all
.
get_result
(
"所有"
,
4
,
"ctr"
)
top_diary_ios
=
TopFeatures
(
"ios"
,
"diary"
,
100
)
clk_diary_times_ios
=
top_diary_ios
.
get_click_times
()
imp_diary_times_ios
=
top_diary_ios
.
get_impression_times
()
clk_diary_ctr_ios
=
top_diary_ios
.
get_result
(
"苹果"
,
clk_diary_times_ios
,
imp_diary_times_ios
,
4
,
"ctr"
)
clk_diary_ctr_ios
=
top_diary_ios
.
get_result
(
"苹果"
,
4
,
"ctr"
)
top_diary_android
=
TopFeatures
(
"android"
,
"diary"
,
100
)
clk_diary_times_android
=
top_diary_android
.
get_click_times
()
imp_diary_times_android
=
top_diary_android
.
get_impression_times
()
clk_diary_ctr_android
=
top_diary_android
.
get_result
(
"安卓"
,
clk_diary_times_android
,
imp_diary_times_android
,
4
,
"ctr"
)
clk_diary_ctr_android
=
top_diary_android
.
get_result
(
"安卓"
,
4
,
"ctr"
)
result_lst
=
[
clk_diary_ctr_all
,
clk_diary_ctr_ios
,
clk_diary_ctr_android
]
output_path
=
DIRECTORY_PATH
+
"top100_ctr_diary_{}.txt"
.
format
(
get_yesterday_date
())
...
...
@@ -136,19 +131,13 @@ def main():
#2. Top answer
top_answer_all
=
TopFeatures
(
"all"
,
"answer"
,
100
)
clk_answer_times_all
=
top_answer_all
.
get_click_times
()
imp_answer_times_all
=
top_answer_all
.
get_impression_times
()
clk_answer_ctr_all
=
top_answer_all
.
get_result
(
"所有"
,
clk_answer_times_all
,
imp_answer_times_all
,
2
,
"ctr"
)
clk_answer_ctr_all
=
top_answer_all
.
get_result
(
"所有"
,
2
,
"ctr"
)
top_answer_ios
=
TopFeatures
(
"ios"
,
"answer"
,
100
)
clk_answer_times_ios
=
top_answer_ios
.
get_click_times
()
imp_answer_times_ios
=
top_answer_ios
.
get_impression_times
()
clk_answer_ctr_ios
=
top_answer_ios
.
get_result
(
"苹果"
,
clk_answer_times_ios
,
imp_answer_times_ios
,
2
,
"ctr"
)
clk_answer_ctr_ios
=
top_answer_ios
.
get_result
(
"苹果"
,
2
,
"ctr"
)
top_answer_android
=
TopFeatures
(
"android"
,
"answer"
,
100
)
clk_answer_times_android
=
top_answer_android
.
get_click_times
()
imp_answer_times_android
=
top_answer_android
.
get_impression_times
()
clk_answer_ctr_android
=
top_answer_android
.
get_result
(
"安卓"
,
clk_answer_times_android
,
imp_answer_times_android
,
2
,
"ctr"
)
clk_answer_ctr_android
=
top_answer_android
.
get_result
(
"安卓"
,
2
,
"ctr"
)
result_lst
=
[
clk_answer_ctr_all
,
clk_answer_ctr_ios
,
clk_answer_ctr_android
]
output_path
=
DIRECTORY_PATH
+
"top100_ctr_answer_{}.txt"
.
format
(
get_yesterday_date
())
...
...
@@ -158,19 +147,13 @@ def main():
#3. Top question
top_question_all
=
TopFeatures
(
"all"
,
"question"
,
100
)
clk_question_times_all
=
top_question_all
.
get_click_times
()
imp_question_times_all
=
top_question_all
.
get_impression_times
()
clk_question_ctr_all
=
top_question_all
.
get_result
(
"所有"
,
clk_question_times_all
,
imp_question_times_all
,
2
,
"ctr"
)
clk_question_ctr_all
=
top_question_all
.
get_result
(
"所有"
,
2
,
"ctr"
)
top_question_ios
=
TopFeatures
(
"ios"
,
"question"
,
100
)
clk_question_times_ios
=
top_question_ios
.
get_click_times
()
imp_question_times_ios
=
top_question_ios
.
get_impression_times
()
clk_question_ctr_ios
=
top_question_ios
.
get_result
(
"苹果"
,
clk_question_times_ios
,
imp_question_times_ios
,
2
,
"ctr"
)
clk_question_ctr_ios
=
top_question_ios
.
get_result
(
"苹果"
,
2
,
"ctr"
)
top_question_android
=
TopFeatures
(
"android"
,
"question"
,
100
)
clk_question_times_android
=
top_question_android
.
get_click_times
()
imp_question_times_android
=
top_question_android
.
get_impression_times
()
clk_question_ctr_android
=
top_question_android
.
get_result
(
"安卓"
,
clk_question_times_android
,
imp_question_times_android
,
2
,
"ctr"
)
clk_question_ctr_android
=
top_question_android
.
get_result
(
"安卓"
,
2
,
"ctr"
)
result_lst
=
[
clk_question_ctr_all
,
clk_question_ctr_ios
,
clk_question_ctr_android
]
output_path
=
DIRECTORY_PATH
+
"top100_ctr_question_{}.txt"
.
format
(
get_yesterday_date
())
...
...
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