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

update

parent a99f16c7
......@@ -84,16 +84,31 @@ def get_user_service_portrait_not_alipay(cl_id, all_word_tags, all_tag_tag_type,
def get_2_tags_coincide_rate(device_order_tags, device_portrait_result, portrait_top_n, coincide_n):
device_count = len(device_order_tags)
coincide_count = 0
not_coincide_no_portrait = 0
not_coincide_no_portrait_device_ids = []
not_coincide_have_portrait_device_ids = []
not_coincide_have_portrait = 0
for device in device_order_tags:
order_tags = device_order_tags[device]
portrait_tags = device_portrait_result[device]
if portrait_tags:
portrait_tags = portrait_tags[:portrait_top_n]
else:
portrait_tags = []
not_coincide_no_portrait += 1
not_coincide_no_portrait_device_ids.append(device)
continue
if len(set(order_tags).intersection(set(portrait_tags))) >= coincide_n:
coincide_count += 1
return coincide_count/device_count
else:
not_coincide_have_portrait += 1
not_coincide_have_portrait_device_ids.append(device)
coincide_rate = coincide_count/device_count
result = {"device_count": device_count, "coincide_count": coincide_count, "coincide_rate": coincide_rate,
"not_coincide_have_portrait_count": not_coincide_have_portrait,
"not_coincide_no_portrait_count": not_coincide_no_portrait,
"not_coincide_no_portrait_device_ids": not_coincide_no_portrait_device_ids,
"not_coincide_have_portrait_device_ids": not_coincide_have_portrait_device_ids}
return result
if __name__ == '__main__':
......@@ -154,11 +169,21 @@ if __name__ == '__main__':
# 昨天下单了的用户的去除支付行为的画像
all_device_portrait_result = dict()
for device in device_ids_lst:
portrait_result = get_user_service_portrait_not_alipay(device, all_word_tags, all_tag_tag_type, all_3tag_2tag, size=10)
portrait_result = get_user_service_portrait_not_alipay(device, all_word_tags, all_tag_tag_type,
all_3tag_2tag, size=10)
all_device_portrait_result[device] = portrait_result
# 比较两个tag列表的重合率
rate = get_2_tags_coincide_rate(all_device_order_tags, all_device_portrait_result, 3, 1)
print(rate)
cmd_portrait_top_n = sys.argv[1]
cmd_coincide_n = sys.argv[2]
result = get_2_tags_coincide_rate(all_device_order_tags, all_device_portrait_result, cmd_portrait_top_n,
cmd_coincide_n)
print("画像的前n个tag:", cmd_portrait_top_n)
print("重合个数:", cmd_coincide_n)
print("下单人数:", result["device_count"])
print("比对的上的人数:", result["coincide_count"])
print("匹配度:", result["coincide_rate"])
print("比对不上的有画像的人数:", result["not_coincide_have_portrait_count"])
print("比对不上的无画像的人数:", result["not_coincide_no_portrait_count"])
except Exception as e:
print(e)
\ No newline at end of file
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