Browse Source

add cvr model

sunmingze 1 year ago
parent
commit
f174fa2f20

+ 14 - 4
ad-engine-commons/src/main/java/com/tzld/piaoquan/ad/engine/commons/score/model/ThompsonSamplingModel.java

@@ -28,6 +28,10 @@ public class ThompsonSamplingModel extends Model {
     // key = adid, value = <exp, click, conversation>
     private Map<Long, AdActionFeature> thompsonSamplingModel;
 
+    private static final int alpha = 6;
+    private static final int beta_click = 100;
+    private static final int beta_conversion = 1000;
+
     public ThompsonSamplingModel() {
         //配置不同环境的hdfs conf
         this.thompsonSamplingModel = new HashMap<>();
@@ -80,10 +84,16 @@ public class ThompsonSamplingModel extends Model {
     public double score(AdRankItem adRankItem, String ctrOrCVR) {
         double score = 0.0f;
         AdActionFeature adActionFeature = this.thompsonSamplingModel.get(adRankItem.getAdId());
-        if(ctrOrCVR.equals("ctr"))
-            score = this.betaSampler(adActionFeature.getAdClick(), adActionFeature.getAdView());
-        if(ctrOrCVR.equals("cvr"))
-            score = this.betaSampler(adActionFeature.getAdConversion(), adActionFeature.getAdView());
+        if (ctrOrCVR.equals("ctr")){
+            int alpha_ctr = (int) adActionFeature.getAdClick() + this.alpha ;
+            int beta_ctr = this.beta_click + (int)adActionFeature.getAdView() - (int)adActionFeature.getAdClick();
+            score = this.betaSampler(alpha_ctr, beta_ctr);
+        }
+        if (ctrOrCVR.equals("cvr")){
+            int alpha_cvr = (int) adActionFeature.getAdClick() + this.alpha ;
+            int beta_cvr = this.beta_conversion + (int)adActionFeature.getAdView() - (int)adActionFeature.getAdConversion();
+            score = this.betaSampler(alpha_cvr, beta_cvr);
+        }
         return score;
     }