Commit aa7d043a authored by 高雅喆's avatar 高雅喆

fix bug in class TopFeatures of eda/test/

parent 652bfcb4
......@@ -36,7 +36,7 @@ class TopFeatures(object):
def get_impression_times(self):
# rtype : dict
if self.cid_type[-2] == 'e'::
if self.cid_type[-2] == 'e':
self.cid_type = self.cid_type[:-6] + ' ' + self.cid_type[:-6:]
sql = "select cid,count(cid) from data_feed_exposure \
where from_unixtime(time,'%Y-%m-%d')=date_add(curdate(), interval -{0} day) \
......@@ -45,7 +45,7 @@ class TopFeatures(object):
imp_times = tuple2dict(con_sql(sql))
return imp_times
def get_result(self, result_types="ctr", clk, imp, clk_n=2):
def get_result(self, clk, imp, clk_n=2, result_types="ctr"):
"""
result_types : "clk";"imp";"ctr"
clk : dict
......@@ -112,23 +112,21 @@ class TopFeatures(object):
def main():
top_diary = TopFeatures(1, "all", "diary")
clk_diary_times_all = get_click_times()
imp_diary_times_all = get_impression_times()
clk_diary_ctr_all = get_result("ctr", clk_diary_times_all, imp_diary_times_all, top_n=100)
clk_diary_times_all = top_diary.get_click_times()
imp_diary_times_all = top_diary.get_impression_times()
clk_diary_ctr_all = top_diary.get_result("ctr", clk_diary_times_all, imp_diary_times_all, top_n=100)
top_diary = TopFeatures(1, "ios", "diary")
clk_diary_times_ios = get_click_times()
imp_diary_times_ios = get_impression_times()
clk_diary_ctr_ios = get_result("ctr", clk_diary_times_ios, imp_diary_times_ios, top_n=100)
clk_diary_times_ios = top_diary.get_click_times()
imp_diary_times_ios = top_diary.get_impression_times()
clk_diary_ctr_ios = top_diary.get_result("ctr", clk_diary_times_ios, imp_diary_times_ios, top_n=100)
top_diary = TopFeatures(1, "android", "diary")
clk_diary_times_android = get_click_times()
imp_diary_times_android = get_impression_times()
clk_diary_ctr_android = get_result("ctr", clk_diary_times_android, imp_diary_times_android, top_n=100)
clk_diary_times_android = top_diary.get_click_times()
imp_diary_times_android = top_diary.get_impression_times()
clk_diary_ctr_android = top_diary.get_result("ctr", clk_diary_times_android, imp_diary_times_android, top_n=100)
result_lst = [clk_diary_ctr_all, clk_diary_ctr_ios, clk_diary_ctr_android]
output_path = DIRECTORY_PATH + "5top100_ctr_diary_%s.txt"
result2file(result_lst, output_path)
top_diary.result2file(result_lst, output_path)
......
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