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
df3f5c33
Commit
df3f5c33
authored
Aug 09, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.wanmeizhensuo.com:ML/ffm-baseline
change sql for test
parents
3bbfc5f5
c38d6d1a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
13 deletions
+16
-13
getTopFeatures.py
eda/test/getTopFeatures.py
+16
-13
No files found.
eda/test/getTopFeatures.py
View file @
df3f5c33
...
@@ -88,11 +88,12 @@ class TopFeatures(object):
...
@@ -88,11 +88,12 @@ class TopFeatures(object):
def
result2file
(
self
,
result_lst
,
fpath
):
def
result2file
(
self
,
result_lst
,
fpath
):
"""
"""
result_lst : [all
,ios,android
]
result_lst : [all
_result,ios_result,android_result
]
fpath : output filename
fpath : output filename
rtype : none
rtype : none
"""
"""
with
open
(
fpath
,
'w'
)
as
f
:
with
open
(
fpath
,
'w'
)
as
f
:
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
"
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
))
f
.
write
(
"Top {0} {1}
\n
"
.
format
(
self
.
top_n
,
self
.
cid_type
))
sep
=
"=================================================================
\n
"
sep
=
"=================================================================
\n
"
...
@@ -111,22 +112,24 @@ class TopFeatures(object):
...
@@ -111,22 +112,24 @@ class TopFeatures(object):
def
main
():
def
main
():
top_
diary
=
TopFeatures
(
1
,
"all"
,
"diary
"
,
100
)
top_
answer_all
=
TopFeatures
(
1
,
"all"
,
"answer
"
,
100
)
clk_
diary_times_all
=
top_diary
.
get_click_times
()
clk_
answer_times_all
=
top_answer
.
get_click_times
()
imp_
diary_times_all
=
top_diary
.
get_impression_times
()
imp_
answer_times_all
=
top_answer
.
get_impression_times
()
clk_
diary_ctr_all
=
top_diary
.
get_result
(
clk_diary_times_all
,
imp_diary
_times_all
,
4
,
"ctr"
)
clk_
answer_ctr_all
=
top_answer
.
get_result
(
clk_answer_times_all
,
imp_answer
_times_all
,
4
,
"ctr"
)
clk_diary_times_ios
=
top_diary
.
get_click_times
()
top_answer_all
=
TopFeatures
(
1
,
"ios"
,
"answer"
,
100
)
imp_diary_times_ios
=
top_diary
.
get_impression_times
()
clk_answer_times_ios
=
top_answer
.
get_click_times
()
clk_diary_ctr_ios
=
top_diary
.
get_result
(
clk_diary_times_ios
,
imp_diary_times_ios
,
4
,
"ctr"
)
imp_answer_times_ios
=
top_answer
.
get_impression_times
()
clk_answer_ctr_ios
=
top_answer
.
get_result
(
clk_answer_times_ios
,
imp_answer_times_ios
,
4
,
"ctr"
)
clk_diary_times_android
=
top_diary
.
get_click_times
()
top_answer_all
=
TopFeatures
(
1
,
"android"
,
"answer"
,
100
)
imp_diary_times_android
=
top_diary
.
get_impression_times
()
clk_answer_times_android
=
top_answer
.
get_click_times
()
clk_diary_ctr_android
=
top_diary
.
get_result
(
clk_diary_times_android
,
imp_diary_times_android
,
4
,
"ctr"
)
imp_answer_times_android
=
top_answer
.
get_impression_times
()
clk_answer_ctr_android
=
top_answer
.
get_result
(
clk_answer_times_android
,
imp_answer_times_android
,
4
,
"ctr"
)
result_lst
=
[
clk_diary_ctr_all
,
clk_diary_ctr_ios
,
clk_diary_ctr_android
]
result_lst
=
[
clk_diary_ctr_all
,
clk_diary_ctr_ios
,
clk_diary_ctr_android
]
output_path
=
DIRECTORY_PATH
+
"
5
top100_ctr_diary_
%
s.txt"
.
format
(
get_yesterday_date
())
output_path
=
DIRECTORY_PATH
+
"top100_ctr_diary_
%
s.txt"
.
format
(
get_yesterday_date
())
top_
diary
.
result2file
(
result_lst
,
output_path
)
top_
answer_all
.
result2file
(
result_lst
,
output_path
)
...
...
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