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
b49bb083
Commit
b49bb083
authored
Aug 10, 2018
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change paltform in imp at getFeatures.py
parent
ec890291
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
5 deletions
+47
-5
getTopFeatures.py
eda/test/getTopFeatures.py
+47
-5
No files found.
eda/test/getTopFeatures.py
View file @
b49bb083
...
...
@@ -37,7 +37,7 @@ class TopFeatures(object):
def
get_impression_times
(
self
):
# rtype : dict
if
self
.
platform
[
-
2
]
==
'e'
:
self
.
platform
=
self
.
platform
[:
-
6
]
+
' '
+
self
.
platform
[
:
-
6
:]
self
.
platform
=
self
.
platform
[:
-
6
]
+
' '
+
self
.
platform
[
-
6
:]
sql
=
"select cid,count(cid) from data_feed_exposure
\
where from_unixtime(time,'
%
Y-
%
m-
%
d')=date_add(curdate(), interval -{0} day)
\
and device_type{1} and cid_type='{2}'
\
...
...
@@ -97,7 +97,7 @@ class TopFeatures(object):
tplt
=
"{0:
\u3000
<4}
\t
{1:
\u3000
<12}
\t
{2:
\u3000
^6}
\t
{3:
\u3000
^6}
\t
{4:
\u3000
<8}
\t
{5:
\u3000
^15}
\n
"
f
.
write
(
"Top {0} {1}
\n
"
.
format
(
self
.
top_n
,
self
.
cid_type
))
sep
=
"=================================================================
\n
"
header
=
tplt
.
format
(
"平台"
,
"{
}_id"
.
format
(
self
.
cid_type
),
"点击数"
,
"曝光数"
,
"点击率"
,
"{}链接"
.
format
(
self
.
cid_type
))
header
=
tplt
.
format
(
"平台"
,
"{
0}_id"
.
format
(
self
.
cid_type
),
"点击数"
,
"曝光数"
,
"点击率"
,
"{1}链接"
.
format
(
self
.
cid_type
,
self
.
cid_type
))
f
.
write
(
sep
)
f
.
write
(
header
)
for
i
in
result_lst
:
...
...
@@ -112,26 +112,68 @@ class TopFeatures(object):
def
main
():
#1. Top diary
top_diary_all
=
TopFeatures
(
1
,
"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
,
2
,
"ctr"
)
top_diary_ios
=
TopFeatures
(
1
,
"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
,
2
,
"ctr"
)
top_diary_android
=
TopFeatures
(
1
,
"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
,
2
,
"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
())
top_diary_all
.
result2file
(
result_lst
,
output_path
)
#2. Top answer
top_answer_all
=
TopFeatures
(
1
,
"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
,
4
,
"ctr"
)
clk_answer_ctr_all
=
top_answer_all
.
get_result
(
clk_answer_times_all
,
imp_answer_times_all
,
2
,
"ctr"
)
top_answer_ios
=
TopFeatures
(
1
,
"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
,
4
,
"ctr"
)
clk_answer_ctr_ios
=
top_answer_ios
.
get_result
(
clk_answer_times_ios
,
imp_answer_times_ios
,
2
,
"ctr"
)
top_answer_android
=
TopFeatures
(
1
,
"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
,
4
,
"ctr"
)
clk_answer_ctr_android
=
top_answer_android
.
get_result
(
clk_answer_times_android
,
imp_answer_times_android
,
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
())
top_answer_all
.
result2file
(
result_lst
,
output_path
)
#3. Top question
top_question_all
=
TopFeatures
(
1
,
"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"
)
top_question_ios
=
TopFeatures
(
1
,
"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"
)
top_question_android
=
TopFeatures
(
1
,
"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"
)
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
())
top_question_all
.
result2file
(
result_lst
,
output_path
)
if
__name__
==
'__main__'
:
main
()
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