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
59409dca
Commit
59409dca
authored
Aug 09, 2018
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pretty output of recommended_indexs
parent
3fcaa79f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
55 deletions
+29
-55
getClickTimes2CountUid.py
eda/recommended_indexs/code/getClickTimes2CountUid.py
+3
-2
getRate.py
eda/recommended_indexs/code/getRate.py
+13
-28
getTop100Answer.py
eda/recommended_indexs/code/getTop100Answer.py
+4
-8
getTop100Diary.py
eda/recommended_indexs/code/getTop100Diary.py
+4
-8
getTop100Question.py
eda/recommended_indexs/code/getTop100Question.py
+5
-9
No files found.
eda/recommended_indexs/code/getClickTimes2CountUid.py
View file @
59409dca
...
...
@@ -31,12 +31,13 @@ def get_click_times_to_count_uid_df():
def
df2file
(
df
,
fpath
):
with
open
(
fpath
,
"w"
)
as
f
:
tplt
=
"{0:^10}
\t
{1:^10}
\n
"
f
.
write
(
"#2. Top特征
\n
"
)
f
.
write
(
"=================================================================
\n
"
)
f
.
write
(
"2.1用户点击次数分布(第一列:用户点击次数;第二列:独立用户数量)
\n
"
)
f
.
write
(
"click_times"
+
"
\t
"
+
"count_uid"
+
"
\n
"
)
f
.
write
(
tplt
.
format
(
"click_times"
,
"count_uid"
)
)
for
row
in
df
.
iterrows
():
line
=
str
(
row
[
1
][
0
])
+
"
\t
"
+
str
(
row
[
1
][
1
])
+
"
\n
"
line
=
tplt
.
format
(
row
[
1
][
0
],
row
[
1
][
1
])
f
.
write
(
line
)
f
.
write
(
"
\n\n
"
)
...
...
eda/recommended_indexs/code/getRate.py
View file @
59409dca
...
...
@@ -15,78 +15,63 @@ def get_yesterday_date():
def
result2file
(
fpath
):
with
open
(
fpath
,
'w'
)
as
f
:
tplt
=
"{0:<6}
\t
{1:^10}
\t
{2:^10}
\t
{3:^10}
\n
"
f
.
write
(
"#注意:以下数据都是首页的
\n
"
)
f
.
write
(
"#1. 比例特征
\n
"
)
f
.
write
(
"=================================================================
\n
"
)
f
.
write
(
"#1.1answer曝光占比(=answer被曝光数/总cid被曝光数)
\n
"
)
f
.
write
(
"平台"
+
"
\t
"
+
"answer被曝光数"
+
"
\t
"
+
"总cid被曝光数"
+
"
\t
"
+
"answer被曝光数占比
\n
"
)
f
.
write
(
tplt
.
format
(
"平台"
,
"answer被曝光数"
,
"总cid被曝光数"
,
"answer被曝光数占比"
)
)
all_answer_imp_rate
=
get_all_answer_imp_rate
()
ios_answer_imp_rate
=
get_ios_answer_imp_rate
()
android_answer_imp_rate
=
get_android_answer_imp_rate
()
lst
=
[
all_answer_imp_rate
,
ios_answer_imp_rate
,
android_answer_imp_rate
]
for
i
in
lst
:
line
=
""
for
j
in
i
:
line
+=
str
(
j
)
+
'
\t
'
line
=
line
[:
-
1
]
+
'
\n
'
line
=
tplt
.
format
(
i
[
0
],
i
[
1
],
i
[
2
],
i
[
3
])
f
.
write
(
line
)
print
(
"1.1已将answer曝光占比存入文件"
)
f
.
write
(
"#1.2
有点击用户点击率(=有点击用户点击次数/有点击
用户曝光次数)
\n
"
)
f
.
write
(
"平台"
+
"
\t
"
+
"有点击用户点击次数"
+
"
\t
"
+
"有点击用户曝光次数"
+
"
\t
"
+
"有点击用户点击率
\n
"
)
f
.
write
(
"#1.2
活跃用户点击率(=活跃用户点击次数/活跃
用户曝光次数)
\n
"
)
f
.
write
(
tplt
.
format
(
"平台"
,
"活跃用户点击次数"
,
"活跃用户曝光次数"
,
"活跃用户点击率"
)
)
all_click_one_rate
=
get_all_click_one_rate
()
ios_click_one_rate
=
get_ios_click_one_rate
()
android_click_one_rate
=
get_android_click_one_rate
()
lst
=
[
all_click_one_rate
,
ios_click_one_rate
,
android_click_one_rate
]
for
i
in
lst
:
line
=
""
for
j
in
i
:
line
+=
str
(
j
)
+
'
\t
'
line
=
line
[:
-
1
]
+
'
\n
'
line
=
tplt
.
format
(
i
[
0
],
i
[
1
],
i
[
2
],
i
[
3
])
f
.
write
(
line
)
print
(
"1.2已将
有点击
用户点击率存入文件"
)
print
(
"1.2已将
活跃
用户点击率存入文件"
)
f
.
write
(
"#1.3点击answer用户占比(=点击answer用户数/曝光answer用户数)
\n
"
)
f
.
write
(
"平台"
+
"
\t
"
+
"点击answer用户数"
+
"
\t
"
+
"曝光answer用户数"
+
"
\t
"
+
"点击answer用户占比
\n
"
)
f
.
write
(
tplt
.
format
(
"平台"
,
"点击answer用户数"
,
"曝光answer用户数"
,
"击answer用户占比"
)
)
all_click_answer_rate
=
get_all_click_answer_rate
()
ios_click_answer_rate
=
get_ios_click_answer_rate
()
android_click_answer_rate
=
get_android_click_answer_rate
()
lst
=
[
all_click_answer_rate
,
ios_click_answer_rate
,
android_click_answer_rate
]
for
i
in
lst
:
line
=
""
for
j
in
i
:
line
+=
str
(
j
)
+
'
\t
'
line
=
line
[:
-
1
]
+
'
\n
'
line
=
tplt
.
format
(
i
[
0
],
i
[
1
],
i
[
2
],
i
[
3
])
f
.
write
(
line
)
print
(
"1.3已将点击answer用户占比存入文件"
)
f
.
write
(
"#1.4点击diary用户占比(=点击diary用户数/曝光diary用户数)
\n
"
)
f
.
write
(
"平台"
+
"
\t
"
+
"点击diary用户数"
+
"
\t
"
+
"曝光diary用户数"
+
"
\t
"
+
"点击diary用户占比
\n
"
)
f
.
write
(
tplt
.
format
(
"平台"
,
"点击diary用户数"
,
"曝光diary用户数"
,
"击diary用户占比"
)
)
all_click_diary_rate
=
get_all_click_diary_rate
()
ios_click_diary_rate
=
get_ios_click_diary_rate
()
android_click_diary_rate
=
get_android_click_diary_rate
()
lst
=
[
all_click_diary_rate
,
ios_click_diary_rate
,
android_click_diary_rate
]
for
i
in
lst
:
line
=
""
for
j
in
i
:
line
+=
str
(
j
)
+
'
\t
'
line
=
line
[:
-
1
]
+
'
\n
'
line
=
tplt
.
format
(
i
[
0
],
i
[
1
],
i
[
2
],
i
[
3
])
f
.
write
(
line
)
print
(
"1.4已将点击diary用户占比存入文件"
)
f
.
write
(
"#1.5无点击用户占比(=无点击用户数/有曝光用户数)
\n
"
)
f
.
write
(
"平台"
+
"
\t
"
+
"无点击用户数"
+
"
\t
"
+
"有曝光用户数"
+
"
\t
"
+
"无点击用户占比
\n
"
)
f
.
write
(
tplt
.
format
(
"平台"
,
"无点击用户数"
,
"有曝光用户数"
,
"无点击用户占比"
)
)
all_click_zero_rate
=
get_all_click_zero_rate
()
ios_click_zero_rate
=
get_ios_click_zero_rate
()
android_click_zero_rate
=
get_android_click_zero_rate
()
lst
=
[
all_click_zero_rate
,
ios_click_zero_rate
,
android_click_zero_rate
]
for
i
in
lst
:
line
=
""
for
j
in
i
:
line
+=
str
(
j
)
+
'
\t
'
line
=
line
[:
-
1
]
+
'
\n
'
line
=
tplt
.
format
(
i
[
0
],
i
[
1
],
i
[
2
],
i
[
3
])
f
.
write
(
line
)
f
.
write
(
'
\n\n
'
)
print
(
"1.5已将无点击用户占比存入文件"
)
...
...
eda/recommended_indexs/code/getTop100Answer.py
View file @
59409dca
...
...
@@ -20,20 +20,16 @@ def tuple2dict(tuple_result):
def
result2file
(
result_lst
,
fpath
):
with
open
(
fpath
,
'w'
)
as
f
:
header
=
"平台"
+
'
\t
'
+
"answer_id"
+
'
\t
'
+
"answer被点击数"
+
'
\t
'
+
"answer被曝光数"
+
'
\t
'
+
"answer被点击率"
+
'
\t
'
+
"answer链接"
+
'
\n
'
tplt
=
"{0:<6}
\t
{1:<10}
\t
{2:^10}
\t
{3:^10}
\t
{4:^10}
\t
{5:<10}
\n
"
f
.
write
(
"Top 100 Answer
\n
"
)
f
.
write
(
"=================================================================
\n
"
)
f
.
write
(
header
)
f
.
write
(
tplt
.
format
(
"平台"
,
"answer_id"
,
"answer被点击数"
,
"answer被曝光数"
,
"answer被点击率"
,
"answer链接"
)
)
for
i
in
result_lst
:
for
j
in
i
:
line
=
""
for
k
in
j
:
line
+=
str
(
k
)
+
'
\t
'
line
=
line
[:
-
1
]
+
'
\n
'
f
.
write
(
line
)
f
.
write
(
tplt
.
format
(
j
[
0
],
j
[
1
],
j
[
2
],
j
[
3
],
j
[
4
],
j
[
5
]))
f
.
write
(
"=================================================================
\n
"
)
if
i
!=
result_lst
[
-
1
]:
f
.
write
(
header
)
f
.
write
(
tplt
.
format
(
"平台"
,
"answer_id"
,
"answer被点击数"
,
"answer被曝光数"
,
"answer被点击率"
,
"answer链接"
)
)
f
.
write
(
"
\n\n
"
)
...
...
eda/recommended_indexs/code/getTop100Diary.py
View file @
59409dca
...
...
@@ -20,20 +20,16 @@ def tuple2dict(tuple_result):
def
result2file
(
result_lst
,
fpath
):
with
open
(
fpath
,
'w'
)
as
f
:
header
=
"平台"
+
'
\t
'
+
"diary_id"
+
'
\t
'
+
"diary被点击数"
+
'
\t
'
+
"diary被曝光数"
+
'
\t
'
+
"diary被点击率"
+
'
\t
'
+
"diary链接"
+
'
\n
'
tplt
=
"{0:<6}
\t
{1:<10}
\t
{2:^10}
\t
{3:^10}
\t
{4:^10}
\t
{5:<10}
\n
"
f
.
write
(
"Top 100 diary
\n
"
)
f
.
write
(
"=================================================================
\n
"
)
f
.
write
(
header
)
f
.
write
(
tplt
.
format
(
"平台"
,
"diary_id"
,
"diary被点击数"
,
"diary被曝光数"
,
"diary被点击率"
,
"diary链接"
)
)
for
i
in
result_lst
:
for
j
in
i
:
line
=
""
for
k
in
j
:
line
+=
str
(
k
)
+
'
\t
'
line
=
line
[:
-
1
]
+
'
\n
'
f
.
write
(
line
)
f
.
write
(
tplt
.
format
(
j
[
0
],
j
[
1
],
j
[
2
],
j
[
3
],
j
[
4
],
j
[
5
]))
f
.
write
(
"=================================================================
\n
"
)
if
i
!=
result_lst
[
-
1
]:
f
.
write
(
header
)
f
.
write
(
tplt
.
format
(
"平台"
,
"diary_id"
,
"diary被点击数"
,
"diary被曝光数"
,
"diary被点击率"
,
"diary链接"
)
)
f
.
write
(
"
\n\n
"
)
...
...
eda/recommended_indexs/code/getTop100Question.py
View file @
59409dca
...
...
@@ -20,20 +20,16 @@ def tuple2dict(tuple_result):
def
result2file
(
result_lst
,
fpath
):
with
open
(
fpath
,
'w'
)
as
f
:
header
=
"平台"
+
'
\t
'
+
"question_id"
+
'
\t
'
+
"question被点击数"
+
'
\t
'
+
"question被曝光数"
+
'
\t
'
+
"question被点击率"
+
'
\t
'
+
"question链接"
+
'
\n
'
f
.
write
(
"Top 100
q
uestion
\n
"
)
tplt
=
"{0:<6}
\t
{1:<10}
\t
{2:^10}
\t
{3:^10}
\t
{4:^10}
\t
{5:<10}
\n
"
f
.
write
(
"Top 100
Q
uestion
\n
"
)
f
.
write
(
"=================================================================
\n
"
)
f
.
write
(
header
)
f
.
write
(
tplt
.
format
(
"平台"
,
"question_id"
,
"question被点击数"
,
"question被曝光数"
,
"question被点击率"
,
"question链接"
)
)
for
i
in
result_lst
:
for
j
in
i
:
line
=
""
for
k
in
j
:
line
+=
str
(
k
)
+
'
\t
'
line
=
line
[:
-
1
]
+
'
\n
'
f
.
write
(
line
)
f
.
write
(
tplt
.
format
(
j
[
0
],
j
[
1
],
j
[
2
],
j
[
3
],
j
[
4
],
j
[
5
]))
f
.
write
(
"=================================================================
\n
"
)
if
i
!=
result_lst
[
-
1
]:
f
.
write
(
header
)
f
.
write
(
tplt
.
format
(
"平台"
,
"question_id"
,
"question被点击数"
,
"question被曝光数"
,
"question被点击率"
,
"question链接"
)
)
f
.
write
(
"
\n\n
"
)
...
...
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