Commit 30cd77b5 authored by 高雅喆's avatar 高雅喆

update

parent 5dc2f162
......@@ -41,7 +41,7 @@ def compute_validate(x):
return score
else:
return 0.5
def tag_list2dict(lst,size):
def tag_list2dict(lst):
result = []
if lst:
for i in lst:
......@@ -53,11 +53,11 @@ def tag_list2dict(lst,size):
tmp["type"] = "search_word"
tmp["score"] = i["tag_score"]
result.append(tmp)
return result[:size]
return result
def get_user_tag_score(cl_id, all_log_df):
user_log_df = all_log_df.loc(all_log_df['cl_id'] == cl_id)
user_log_df = all_log_df.loc[all_log_df['cl_id'] == cl_id]
if not user_log_df.empty:
user_log_df["tag_id"] = np.where(user_log_df["action"] == "do_search",user_log_df["tag_referrer"],user_log_df["tag_id"])
user_log_df["days_diff_now"] = round((int(time.time())-user_log_df["time"]) / (24*60*60))
......@@ -68,7 +68,7 @@ def get_user_tag_score(cl_id, all_log_df):
finally_score = user_log_df.sort_values(by=["tag_score","time"],ascending=False)
finally_score.drop_duplicates(subset="tag_id", inplace=True)
finally_score_lst = finally_score[["tag_id","tag_score"]].to_dict('record')
tag_id_list = tag_list2dict(finally_score_lst,size)
tag_id_list = tag_list2dict(finally_score_lst)
return cl_id, tag_id_list
else:
return ()
......
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