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

update

parent c58ac417
......@@ -200,7 +200,7 @@ def get_action_tag_count(df, action_time):
print(e)
def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2tag):
def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2tag, size=10):
try:
db_jerry_test = pymysql.connect(host='172.16.40.158', port=4000, user='root', passwd='3SYz54LS9#^9sBvC',
db='jerry_test', charset='utf8')
......@@ -248,7 +248,7 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2
compute_validate(x.days_diff_now)/get_action_tag_count(user_df_service, x.time)))), axis=1)
tag_score_sum = user_df_service.groupby(by=["tag2", "tag2_type"]).agg({'tag_score': sum}).reset_index().sort_values(by=["tag_score"],ascending=False)
tag_score_sum['weight'] = 100 * tag_score_sum['tag_score'] / tag_score_sum['tag_score'].sum()
gmkv_tag_score_sum = tag_score_sum[["tag2", "tag_score", "weight"]].to_dict('record')
gmkv_tag_score_sum = tag_score_sum[["tag2", "tag_score", "weight"]][:size].to_dict('record')
# 写gmkv
gm_kv_cli = redis.Redis(host="172.16.40.135", port=5379, db=2, socket_timeout=2000)
cl_id_portrait_key = "user:service_portrait_tags:cl_id:" + str(cl_id)
......
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