|
@@ -676,7 +676,7 @@ def video_new_rank2(data, size, top_K, flow_pool_P, ab_code):
|
|
|
i += 1
|
|
|
return rank_result[:size]
|
|
|
|
|
|
-def video_sanke_rank(data, size, top_K, flow_pool_P, ab_Code=''):
|
|
|
+def video_sanke_rank(data, size, top_K, flow_pool_P, ab_Code='', test_config=None):
|
|
|
"""
|
|
|
视频分发排序
|
|
|
:param data: 各路召回的视频 type-dict {'rov_pool_recall': [], 'flow_pool_recall': []}
|
|
@@ -694,25 +694,21 @@ def video_sanke_rank(data, size, top_K, flow_pool_P, ab_Code=''):
|
|
|
if item.get('pushFrom') == config_.PUSH_FROM['rov_recall_region_h']]
|
|
|
region_h_recall_rank = sorted(region_h_recall, key=lambda k: k.get('rovScore', 0), reverse=True)
|
|
|
recall_dict['rov_recall_region_h'] = region_h_recall_rank
|
|
|
- print("rov_recall_region_h:", len(region_h_recall_rank))
|
|
|
# 地域分组小时级更新24h规则更新数据
|
|
|
region_24h_recall = [item for item in data['rov_pool_recall']
|
|
|
if item.get('pushFrom') == config_.PUSH_FROM['rov_recall_region_24h']]
|
|
|
region_24h_recall_rank = sorted(region_24h_recall, key=lambda k: k.get('rovScore', 0), reverse=True)
|
|
|
recall_dict['rov_recall_region_24h'] = region_24h_recall_rank
|
|
|
- print("rov_recall_region_24h:", len(region_24h_recall_rank))
|
|
|
|
|
|
# 相对24h规则更新数据
|
|
|
rule_24h_recall = [item for item in data['rov_pool_recall']
|
|
|
if item.get('pushFrom') == config_.PUSH_FROM['rov_recall_24h']]
|
|
|
rule_24h_recall_rank = sorted(rule_24h_recall, key=lambda k: k.get('rovScore', 0), reverse=True)
|
|
|
- print("rov_recall_24h:", len(rule_24h_recall_rank))
|
|
|
recall_dict['rov_recall_24h'] = rule_24h_recall_rank
|
|
|
# 相对24h规则筛选后剩余更新数据
|
|
|
rule_24h_dup_recall = [item for item in data['rov_pool_recall']
|
|
|
if item.get('pushFrom') == config_.PUSH_FROM['rov_recall_24h_dup']]
|
|
|
rule_24h_dup_recall_rank = sorted(rule_24h_dup_recall, key=lambda k: k.get('rovScore', 0), reverse=True)
|
|
|
- print("rov_recall_24h_dup:", len(rule_24h_dup_recall_rank))
|
|
|
recall_dict['rov_recall_24h_dup'] = rule_24h_dup_recall_rank
|
|
|
hot_recall = []
|
|
|
w2v_recall =[]
|
|
@@ -722,16 +718,17 @@ def video_sanke_rank(data, size, top_K, flow_pool_P, ab_Code=''):
|
|
|
hot_recall = sorted(data['hot_recall'], key=lambda k: k.get('rovScore', 0), reverse=True)
|
|
|
recall_dict['hot_recall'] = hot_recall
|
|
|
elif ab_Code==60059:
|
|
|
- #print(data['w2v_recall'])
|
|
|
if len(data['w2v_recall'])>0:
|
|
|
recall_dict['w2v_recall'] = data['w2v_recall']
|
|
|
else:
|
|
|
recall_dict['w2v_recall'] = w2v_recall
|
|
|
- print("recall_dict['w2v_recall']", recall_dict['w2v_recall'])
|
|
|
|
|
|
recall_list = [('rov_recall_region_h',1, 1),('hot_recall',0.5,1), ('w2v_recall',0.5,1),
|
|
|
('rov_recall_region_h',0.5, 1),('rov_recall_region_24h',1,1),
|
|
|
('rov_recall_24h',1,1), ('rov_recall_24h_dup',0.5,1)]
|
|
|
+ if not test_config:
|
|
|
+ recall_list = test_config
|
|
|
+ print("recall_list:", recall_list)
|
|
|
rov_recall_rank = []
|
|
|
select_ids = set('')
|
|
|
for i in range(3):
|
|
@@ -741,13 +738,11 @@ def video_sanke_rank(data, size, top_K, flow_pool_P, ab_Code=''):
|
|
|
per_recall_name = per_recall_item[0]
|
|
|
per_recall_freq = per_recall_item[1]
|
|
|
per_limt_num = per_recall_item[2]
|
|
|
- #rand_num = random.random()
|
|
|
- print("per_recall_item:", per_recall_name, "per_recall_freq:", per_recall_freq)
|
|
|
+ rand_num = random.random()
|
|
|
#print(recall_dict[per_recall_name])
|
|
|
- rand_num = 0.2
|
|
|
if rand_num<per_recall_freq and per_recall_name in recall_dict:
|
|
|
per_recall = recall_dict[per_recall_name]
|
|
|
- print("per_recall_item:", per_recall_item)
|
|
|
+ #print("per_recall_item:", per_recall_item)
|
|
|
cur_recall_num = 0
|
|
|
for recall_item in per_recall:
|
|
|
vid = recall_item['videoId']
|
|
@@ -758,8 +753,8 @@ def video_sanke_rank(data, size, top_K, flow_pool_P, ab_Code=''):
|
|
|
cur_recall_num+=1
|
|
|
if cur_recall_num>=per_limt_num:
|
|
|
break
|
|
|
- print("rov_recall_rank:")
|
|
|
- print(rov_recall_rank)
|
|
|
+ # print("rov_recall_rank:")
|
|
|
+ # print(rov_recall_rank)
|
|
|
#rov_recall_rank = region_h_recall_rank + region_24h_recall_rank + \
|
|
|
# rule_24h_recall_rank + rule_24h_dup_recall_rank
|
|
|
# 流量池
|