Commit 233a458a authored by 高雅喆's avatar 高雅喆

argparse

parent 0e5c0a3b
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
import sys import argparse
import pymysql import pymysql
import redis import redis
import datetime import datetime
...@@ -114,12 +114,18 @@ def get_2_tags_coincide_rate(device_order_tags, device_portrait_result, portrait ...@@ -114,12 +114,18 @@ def get_2_tags_coincide_rate(device_order_tags, device_portrait_result, portrait
if __name__ == '__main__': if __name__ == '__main__':
try: try:
# 获取昨天下单的用户设备id,下单的美购,美购对应的tag parser = argparse.ArgumentParser(description='画像匹配度的统计')
# api_order只有用户的user_id,一个user_id对应多个device_id parser.add_argument("-t", "--top", type=int, dest="portrait_top_n", default=3, help="选取画像的前n个tag去统计匹配度")
# 用户一次可以下多个订单(美购),一个美购对应多个tag parser.add_argument("-c", "--coincide", type=int, dest="coincide_n", default=1, help="选取n个tag重合个数作为判断是否匹配的阈值")
args = parser.parse_args()
LOG_DIR = "/home/gmuser/gyz/log/" LOG_DIR = "/home/gmuser/gyz/log/"
my_today = str(datetime.date.today()) my_today = str(datetime.date.today())
my_yesterday = str(datetime.date.today() - datetime.timedelta(days=1)) my_yesterday = str(datetime.date.today() - datetime.timedelta(days=1))
# 获取昨天下单的用户设备id,下单的美购,美购对应的tag
# api_order只有用户的user_id,一个user_id对应多个device_id
# 用户一次可以下多个订单(美购),一个美购对应多个tag
sql_order_device_info_yesterday = """ sql_order_device_info_yesterday = """
SELECT tmp1.user_id, SELECT tmp1.user_id,
c.device_id, c.device_id,
...@@ -185,8 +191,8 @@ if __name__ == '__main__': ...@@ -185,8 +191,8 @@ if __name__ == '__main__':
all_device_portrait_result[device] = portrait_result all_device_portrait_result[device] = portrait_result
# 比较两个tag列表的重合率 # 比较两个tag列表的重合率
cmd_portrait_top_n = int(sys.argv[1]) cmd_portrait_top_n = args.portrait_top_n
cmd_coincide_n = int(sys.argv[2]) cmd_coincide_n = args.coincide_n
result = get_2_tags_coincide_rate(all_device_order_tags2, all_device_portrait_result, cmd_portrait_top_n, result = get_2_tags_coincide_rate(all_device_order_tags2, all_device_portrait_result, cmd_portrait_top_n,
cmd_coincide_n) cmd_coincide_n)
......
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