Commit 1caba335 authored by 张彦钊's avatar 张彦钊

Merge branch 'master' of git.wanmeizhensuo.com:ML/ffm-baseline

add multi get_eachCityDiaryTop3000
parents e72f288f 399e04ee
...@@ -128,11 +128,22 @@ def get_rate_detail(platform): ...@@ -128,11 +128,22 @@ def get_rate_detail(platform):
db.close() db.close()
return result return result
def result2dict(result):
"""
result : tuple2
rtype : dict
"""
dct = {}
sum_count = 0
for i in result:
sum_count += i[1]
for i in result:
dct[i[0]] = "{}%".format(round(i[1]/sum_count*100,2))
return dct
no_click_uid_detail_all = result2dict(get_rate_detail("all"))
no_click_uid_detail_all = get_rate_detail("all") no_click_uid_detail_ios = result2dict(get_rate_detail("ios"))
no_click_uid_detail_ios = get_rate_detail("ios") no_click_uid_detail_android = result2dict(get_rate_detail("android"))
no_click_uid_detail_android = get_rate_detail("android")
......
...@@ -18,14 +18,16 @@ def result2file(fpath): ...@@ -18,14 +18,16 @@ def result2file(fpath):
with open(fpath,'w') as f: with open(fpath,'w') as f:
tplt = "{0:\u3000<6}\t{1:\u3000<15}\t{2:\u3000<15}\t{3:\u3000<15}\n" tplt = "{0:\u3000<6}\t{1:\u3000<15}\t{2:\u3000<15}\t{3:\u3000<15}\n"
line = """数据日期:{} line = """数据日期:{}
内容概览:以下所有数据都是首页的 内容概览:以下所有数据都是昨天一天的首页的
1. 比例特征 1. 比例特征
1.1 answer曝光占比(=answer被曝光数/总cid被曝光数) 1.1 answer曝光占比(=answer被曝光数/总cid被曝光数)
1.2 diary曝光占比(=diary被曝光数/总cid被曝光数) 1.2 diary曝光占比(=diary被曝光数/总cid被曝光数)
1.3 活跃用户点击率(=有点击用户点击次数/有点击用户曝光次数) 1.3 活跃用户点击率(=有点击用户点击次数/有点击用户曝光次数)
1.4 点击answer用户占比(=点击answer用户数/曝光answer用户数) 1.4 活跃用户平均每天曝光次数(活跃用户指的是有点击的用户)
1.5 点击diary用户占比(=点击diary用户数/曝光diary用户数) 1.5 点击answer用户占比(=点击answer用户数/曝光answer用户数)
1.6 无点击用户占比(=无点击用户数/有曝光用户数) 1.6 点击diary用户占比(=点击diary用户数/曝光diary用户数)
1.7 无点击用户占比(=无点击用户数/有曝光用户数)
1.8 无点击用户数分布占比(根据激活日期和平台来分)
2.Top特征 2.Top特征
2.1 用户点击次数分布(第一列:用户点击次数;第二列:独立用户数量) 2.1 用户点击次数分布(第一列:用户点击次数;第二列:独立用户数量)
2.2 Top 100 diary (sorted by ctr) 2.2 Top 100 diary (sorted by ctr)
...@@ -34,7 +36,7 @@ def result2file(fpath): ...@@ -34,7 +36,7 @@ def result2file(fpath):
具体内容:以下所有数据都首页的 具体内容:以下所有数据都昨天一天的首页的
""".format(get_yesterday_date()) """.format(get_yesterday_date())
f.write(line) f.write(line)
f.write("#1. 比例特征\n") f.write("#1. 比例特征\n")
...@@ -46,7 +48,7 @@ def result2file(fpath): ...@@ -46,7 +48,7 @@ def result2file(fpath):
android_answer_imp_rate = get_android_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] lst = [all_answer_imp_rate,ios_answer_imp_rate,android_answer_imp_rate]
for i in lst: for i in lst:
line = tplt.format(i[0],i[1],i[2],i[3]) line = tplt.format(i[0],i[1],i[2],"{}%".format(round(i[3]*100,2)))
f.write(line) f.write(line)
f.write('\n') f.write('\n')
print("1.1已将answer曝光占比存入文件") print("1.1已将answer曝光占比存入文件")
...@@ -58,7 +60,7 @@ def result2file(fpath): ...@@ -58,7 +60,7 @@ def result2file(fpath):
android_diary_imp_rate = get_android_diary_imp_rate() android_diary_imp_rate = get_android_diary_imp_rate()
lst = [all_diary_imp_rate,ios_diary_imp_rate,android_diary_imp_rate] lst = [all_diary_imp_rate,ios_diary_imp_rate,android_diary_imp_rate]
for i in lst: for i in lst:
line = tplt.format(i[0],i[1],i[2],i[3]) line = tplt.format(i[0],i[1],i[2],"{}%".format(round(i[3]*100,2)))
f.write(line) f.write(line)
f.write('\n') f.write('\n')
print("1.2已将diary曝光占比存入文件") print("1.2已将diary曝光占比存入文件")
...@@ -70,46 +72,46 @@ def result2file(fpath): ...@@ -70,46 +72,46 @@ def result2file(fpath):
android_click_one_rate = get_android_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] lst = [all_click_one_rate,ios_click_one_rate,android_click_one_rate]
for i in lst: for i in lst:
line = tplt.format(i[0],i[1],i[2],i[3]) line = tplt.format(i[0],i[1],i[2],"{}%".format(round(i[3]*100,2)))
f.write(line) f.write(line)
f.write('\n') f.write('\n')
print("1.3已将活跃用户点击率存入文件") print("1.3已将活跃用户点击率存入文件")
f.write("#1.4点击answer用户占比(=点击answer用户数/曝光answer用户数)\n") f.write("#1.5点击answer用户占比(=点击answer用户数/曝光answer用户数)\n")
f.write(tplt.format("平台","点击answer用户数","曝光answer用户数","击answer用户占比")) f.write(tplt.format("平台","点击answer用户数","曝光answer用户数","击answer用户占比"))
all_click_answer_rate = get_all_click_answer_rate() all_click_answer_rate = get_all_click_answer_rate()
ios_click_answer_rate = get_ios_click_answer_rate() ios_click_answer_rate = get_ios_click_answer_rate()
android_click_answer_rate = get_android_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] lst = [all_click_answer_rate,ios_click_answer_rate,android_click_answer_rate]
for i in lst: for i in lst:
line = tplt.format(i[0],i[1],i[2],i[3]) line = tplt.format(i[0],i[1],i[2],"{}%".format(round(i[3]*100,2)))
f.write(line) f.write(line)
f.write('\n') f.write('\n')
print("1.4已将点击answer用户占比存入文件") print("1.5已将点击answer用户占比存入文件")
f.write("#1.5点击diary用户占比(=点击diary用户数/曝光diary用户数)\n") f.write("#1.6点击diary用户占比(=点击diary用户数/曝光diary用户数)\n")
f.write(tplt.format("平台","点击diary用户数","曝光diary用户数","击diary用户占比")) f.write(tplt.format("平台","点击diary用户数","曝光diary用户数","击diary用户占比"))
all_click_diary_rate = get_all_click_diary_rate() all_click_diary_rate = get_all_click_diary_rate()
ios_click_diary_rate = get_ios_click_diary_rate() ios_click_diary_rate = get_ios_click_diary_rate()
android_click_diary_rate = get_android_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] lst = [all_click_diary_rate,ios_click_diary_rate,android_click_diary_rate]
for i in lst: for i in lst:
line = tplt.format(i[0],i[1],i[2],i[3]) line = tplt.format(i[0],i[1],i[2],"{}%".format(round(i[3]*100,2)))
f.write(line) f.write(line)
f.write('\n') f.write('\n')
print("1.5已将点击diary用户占比存入文件") print("1.6已将点击diary用户占比存入文件")
f.write("#1.6无点击用户占比(=无点击用户数/有曝光用户数)\n") f.write("#1.7无点击用户占比(=无点击用户数/有曝光用户数)\n")
f.write(tplt.format("平台","no点击用户数","have曝光用户数","no点击用户占比")) f.write(tplt.format("平台","no点击用户数","have曝光用户数","no点击用户占比"))
all_click_zero_rate = get_all_click_zero_rate() all_click_zero_rate = get_all_click_zero_rate()
ios_click_zero_rate = get_ios_click_zero_rate() ios_click_zero_rate = get_ios_click_zero_rate()
android_click_zero_rate = get_android_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] lst = [all_click_zero_rate,ios_click_zero_rate,android_click_zero_rate]
for i in lst: for i in lst:
line = tplt.format(i[0],i[1],i[2],i[3]) line = tplt.format(i[0],i[1],i[2],"{}%".format(round(i[3]*100,2)))
f.write(line) f.write(line)
f.write('\n') f.write('\n')
print("1.6已将无点击用户占比存入文件") print("1.7已将无点击用户占比存入文件")
def main(): def main():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment