|
@@ -758,7 +758,7 @@ def video_sanke_rank(data, size, top_K, flow_pool_P, ab_Code='', exp_config=None
|
|
|
recall_dict['w2v_recall'] = data['w2v_recall']
|
|
|
else:
|
|
|
recall_dict['w2v_recall'] = w2v_recall
|
|
|
- elif ab_Code==60061:
|
|
|
+ elif ab_Code==60061 or ab_Code==60063:
|
|
|
if len(data['sim_recall'])>0:
|
|
|
recall_dict['sim_recall'] = data['sim_recall']
|
|
|
else:
|
|
@@ -919,6 +919,7 @@ def video_sank_pos_rank(data, size, top_K, flow_pool_P, ab_Code='', exp_config=N
|
|
|
w2v_recall =[]
|
|
|
sim_recall = []
|
|
|
u2u2i_recall = []
|
|
|
+ return_video_recall = []
|
|
|
if ab_Code==60058:
|
|
|
if len(data['u2i_recall'])>0:
|
|
|
u2i_recall = sorted(data['u2i_recall'], key=lambda k: k.get('rovScore', 0), reverse=True)
|
|
@@ -928,7 +929,7 @@ def video_sank_pos_rank(data, size, top_K, flow_pool_P, ab_Code='', exp_config=N
|
|
|
recall_dict['w2v_recall'] = data['w2v_recall']
|
|
|
else:
|
|
|
recall_dict['w2v_recall'] = w2v_recall
|
|
|
- elif ab_Code==60061:
|
|
|
+ elif ab_Code==60061 or ab_Code==60063:
|
|
|
if len(data['sim_recall'])>0:
|
|
|
recall_dict['sim_recall'] = data['sim_recall']
|
|
|
else:
|
|
@@ -938,15 +939,20 @@ def video_sank_pos_rank(data, size, top_K, flow_pool_P, ab_Code='', exp_config=N
|
|
|
recall_dict['u2u2i_recall'] = data['u2u2i_recall']
|
|
|
else:
|
|
|
recall_dict['u2u2i_recall'] = u2u2i_recall
|
|
|
+ elif ab_Code==60064:
|
|
|
+ if len(data['return_video_recall'])>0:
|
|
|
+ recall_dict['return_video_recall'] = data['return_video_recall']
|
|
|
+ else:
|
|
|
+ recall_dict['return_video_recall'] = return_video_recall
|
|
|
|
|
|
- recall_pos1 = [('rov_recall_region_h',0.98),('rov_recall_24h',0.02),('rov_recall_region_24h',1),
|
|
|
- ('rov_recall_24h',1),('rov_recall_24h_dup',1)]
|
|
|
- recall_pos2 = [('rov_recall_region_h',0.98),('rov_recall_24h',0.02),('rov_recall_region_24h',1),
|
|
|
- ('rov_recall_24h',1),('rov_recall_24h_dup',1)]
|
|
|
- recall_pos3 = [('rov_recall_region_h', 0.98), ('rov_recall_24h', 0.02), ('rov_recall_region_24h', 1),
|
|
|
- ('rov_recall_24h', 1), ('rov_recall_24h_dup', 1)]
|
|
|
- recall_pos4 = [('rov_recall_region_h', 0.98), ('rov_recall_24h', 0.02), ('rov_recall_region_24h', 1),
|
|
|
- ('rov_recall_24h', 1), ('rov_recall_24h_dup', 1)]
|
|
|
+ recall_pos1 = [('rov_recall_region_h',0, 0.98),('rov_recall_24h',0.98, 1),('rov_recall_region_24h',0,1),
|
|
|
+ ('rov_recall_24h',0,1), ('rov_recall_24h_dup',0,1)]
|
|
|
+ recall_pos2 = [('rov_recall_region_h',0,0.98),('rov_recall_24h',0.98,1),('rov_recall_region_24h',0,1),
|
|
|
+ ('rov_recall_24h',0,1),('rov_recall_24h_dup',0,1)]
|
|
|
+ recall_pos3 = [('rov_recall_region_h', 0,0.98), ('rov_recall_24h', 0.98,1), ('rov_recall_region_24h', 0,1),
|
|
|
+ ('rov_recall_24h', 0,1), ('rov_recall_24h_dup', 0,1)]
|
|
|
+ recall_pos4 = [('rov_recall_region_h', 0,0.98), ('rov_recall_24h', 0,0.02), ('rov_recall_region_24h', 0,1),
|
|
|
+ ('rov_recall_24h', 0,1), ('rov_recall_24h_dup', 0,1)]
|
|
|
if exp_config and 'recall_pos1' in exp_config \
|
|
|
and 'recall_pos2' in exp_config \
|
|
|
and 'recall_pos3' in exp_config \
|
|
@@ -963,26 +969,50 @@ def video_sank_pos_rank(data, size, top_K, flow_pool_P, ab_Code='', exp_config=N
|
|
|
recall_list.append(recall_pos3)
|
|
|
recall_list.append(recall_pos4)
|
|
|
select_ids = set('')
|
|
|
+ recall_num_limit_dict = {}
|
|
|
+ if exp_config and 'recall_num_limit' in exp_config:
|
|
|
+ recall_num_limit_dict = exp_config['recall_num_limit']
|
|
|
+ exp_recall_dict = {}
|
|
|
+ #index_pos = 0
|
|
|
for j in range(3):
|
|
|
if len(rov_recall_rank)>12:
|
|
|
break
|
|
|
+ # choose pos
|
|
|
for recall_pos_config in recall_list:
|
|
|
rand_num = random.random()
|
|
|
+ index_pos = 0
|
|
|
+ # choose pos recall
|
|
|
for per_recall_item in recall_pos_config:
|
|
|
+ if index_pos == 1:
|
|
|
+ break
|
|
|
+ if len(per_recall_item)<3:
|
|
|
+ continue
|
|
|
per_recall_name = per_recall_item[0]
|
|
|
- per_recall_freq = per_recall_item[1]
|
|
|
- if rand_num < per_recall_freq and per_recall_name in recall_dict:
|
|
|
+ per_recall_min = float(per_recall_item[1])
|
|
|
+ per_recall_max = float(per_recall_item[2])
|
|
|
+ per_recall_num = exp_recall_dict.get(per_recall_name, 0)
|
|
|
+ per_recall_total_num = recall_num_limit_dict.get(per_recall_name, 0)
|
|
|
+ # recall set total num
|
|
|
+ if len(recall_num_limit_dict)>0 and per_recall_total_num>0 and per_recall_num>= per_recall_total_num:
|
|
|
+ continue
|
|
|
+ if rand_num >= per_recall_min and rand_num < per_recall_max and per_recall_name in recall_dict:
|
|
|
per_recall = recall_dict[per_recall_name]
|
|
|
for recall_item in per_recall:
|
|
|
vid = recall_item['videoId']
|
|
|
if vid in select_ids:
|
|
|
continue
|
|
|
+ recall_item['rand'] = rand_num
|
|
|
rov_recall_rank.append(recall_item)
|
|
|
select_ids.add(vid)
|
|
|
+ if per_recall_name in exp_recall_dict:
|
|
|
+ exp_recall_dict[per_recall_name] +=1
|
|
|
+ else:
|
|
|
+ exp_recall_dict[per_recall_name] = 1
|
|
|
+ index_pos = 1
|
|
|
break
|
|
|
-
|
|
|
+ #print("rov_recall_rank:", rov_recall_rank)
|
|
|
if len(rov_recall_rank)<4:
|
|
|
- rov_doudi_rank = region_h_recall_rank + sim_recall + u2i_recall + u2u2i_recall + w2v_recall + region_24h_recall_rank + rule_24h_recall_rank + rule_24h_dup_recall_rank
|
|
|
+ rov_doudi_rank = region_h_recall_rank + sim_recall + u2i_recall + u2u2i_recall + w2v_recall +return_video_recall+ region_24h_recall_rank + rule_24h_recall_rank + rule_24h_dup_recall_rank
|
|
|
for recall_item in rov_doudi_rank:
|
|
|
vid = recall_item['videoId']
|
|
|
if vid in select_ids:
|