|
@@ -94,15 +94,20 @@ def get_creative_id_with_thompson_weight(mid, creative_id_list, gevent_pool, sor
|
|
|
creative_id = item[0]
|
|
|
creative_weight[creative_id] += (i * config_.WEIGHT_GRADIENT)
|
|
|
|
|
|
- # thompson_score * weight
|
|
|
+ # 对有cvr的creative进行加权
|
|
|
thompson_weight_res_list = []
|
|
|
weight_sum = sum([weight for _, weight in creative_weight.items()])
|
|
|
for thompson_res in thompson_res_list:
|
|
|
creative_id, score = thompson_res[0], thompson_res[1]
|
|
|
- weight_score = score * (1 + creative_weight[creative_id] / weight_sum)
|
|
|
- thompson_weight_res_list.append(thompson_res.add([creative_weight[creative_id], weight_score]))
|
|
|
+ weight = creative_weight[creative_id]
|
|
|
+ if weight > config_.CREATIVE_WEIGHT_INITIAL:
|
|
|
+ weight_score = score * (1 + weight / weight_sum)
|
|
|
+ else:
|
|
|
+ weight_score = score
|
|
|
+ thompson_weight_res = thompson_res + [creative_weight[creative_id], weight_score]
|
|
|
+ thompson_weight_res_list.append(thompson_weight_res)
|
|
|
# 重新排序
|
|
|
- thompson_res_rank = sorted(thompson_weight_res_list, key=lambda x: x[6], reverse=True)
|
|
|
+ thompson_res_rank = sorted(thompson_weight_res_list, key=lambda x: x[7], reverse=True)
|
|
|
rank_res = {
|
|
|
'mid': mid,
|
|
|
'creative_id': thompson_res_rank[0][0],
|