Commit ecc4459a authored by 张彦钊's avatar 张彦钊

统计指标恢复到用老用户做分母

parent 1a0419fc
...@@ -33,12 +33,24 @@ def ctr_all(): ...@@ -33,12 +33,24 @@ def ctr_all():
cursor.execute(sql_active) cursor.execute(sql_active)
result = cursor.fetchall() result = cursor.fetchall()
tail56 = pd.DataFrame(list(result))[0].values.tolist() tail56 = pd.DataFrame(list(result))[0].values.tolist()
cover = len(set(tail56) & set(device_id))
print("当天尾号5或6活跃用户总数:") start = "2018-09-05"
print(len(tail56)) sql_all = "select distinct device_id from data_feed_click " \
"where stat_date >= '{}' and stat_date <= '{}' and cid_type = 'diary'".format(start, date)
cursor.execute(sql_all)
result_all = cursor.fetchall()
df = pd.DataFrame(list(result_all))
all_user = df[0].values.tolist()
print("老用户总数:")
print(len(all_user))
day_all = set(all_user) & set(tail56)
print("当天老用户总数:")
print(len(day_all))
cover = len(day_all & set(device_id))
print("当天尾号5或6活跃用户覆盖数:") print("当天尾号5或6活跃用户覆盖数:")
print(cover) print(cover)
cover_percent = format(cover / len(tail56),".3f") cover_percent = format(cover / len(day_all), ".3f")
print("当天尾号5或6活跃用户覆盖率:") print("当天尾号5或6活跃用户覆盖率:")
print(cover_percent) print(cover_percent)
sql_click = "select count(cid) from data_feed_click " \ sql_click = "select count(cid) from data_feed_click " \
...@@ -54,7 +66,7 @@ def ctr_all(): ...@@ -54,7 +66,7 @@ def ctr_all():
exp = cursor.fetchone()[0] exp = cursor.fetchone()[0]
print("曝光数:" + str(exp)) print("曝光数:" + str(exp))
print("点击率:" + str(click / exp)) print("点击率:" + str(click / exp))
return len(tail56),cover,cover_percent,click,exp,format(click/exp,".6f") return len(day_all),cover,cover_percent,click,exp,format(click/exp,".6f")
def ctr(): def ctr():
......
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