liqian 1 рік тому
батько
коміт
ec0ec95a91
1 змінених файлів з 9 додано та 4 видалено
  1. 9 4
      ad_predict.py

+ 9 - 4
ad_predict.py

@@ -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],