Parcourir la source

加入view500 1000维度打分

gufengshou1 il y a 11 mois
Parent
commit
8fc56bab63

+ 25 - 10
ad-engine-commons/src/main/java/com/tzld/piaoquan/ad/engine/commons/score/model/VideoAdThompsonModel.java

@@ -112,24 +112,40 @@ public class VideoAdThompsonModel extends Model{
         modelCache.put(videoId+"_"+creativeId, adActionFeature);
     }
 
-    public double ctrScore(AdRankItem item) {
+    public double scoreByView1000(AdRankItem item) {
         AdActionFeature adActionFeature = this.featureCache.getOrDefault(item.getVideoId()+"_"+item.getAdId(),  new AdActionFeature());
+        double alpha_score=0d;
+        double beta_score=0d;
         if(adActionFeature.getAdView()<1000){
             adActionFeature=this.adActionFeatureMap.getOrDefault(item.getAdId(), new AdActionFeature());
+            alpha_score =  adActionFeature.getAdConversion() + this.alpha_conv;
+            beta_score = this.beta_conversion + adActionFeature.getAdView() - adActionFeature.getAdConversion();
+        }else {
+            AdActionFeature videoAdFeature=this.videoAdActionFeatureMap.getOrDefault(item.getVideoId(),new AdActionFeature());
+            double k=(videoAdFeature.getAdConversion()+videoAdFeature.getAdView())/1000d;
+            double alpha=(videoAdFeature.getAdConversion())/k;
+            alpha_score =adActionFeature.getAdConversion() + alpha;
+            beta_score = 1000d +  adActionFeature.getAdView() -  adActionFeature.getAdConversion();
         }
-        double alpha_ctr = (int) adActionFeature.getAdClick() + this.alpha_click;
-        double beta_ctr = this.beta_click + (int) adActionFeature.getAdView() - (int) adActionFeature.getAdClick();
-        return this.betaSampler(alpha_ctr, beta_ctr);
+        return this.betaSampler(alpha_score, beta_score);
     }
 
-    public double cvrScore(AdRankItem item) {
+    public double scoreByView500(AdRankItem item) {
         AdActionFeature adActionFeature = this.featureCache.getOrDefault(item.getVideoId()+"_"+item.getAdId(),  new AdActionFeature());
-        if(adActionFeature.getAdView()<1000){
+        double alpha_score=0d;
+        double beta_score=0d;
+        if(adActionFeature.getAdView()<500){
             adActionFeature=this.adActionFeatureMap.getOrDefault(item.getAdId(), new AdActionFeature());
+            alpha_score =  adActionFeature.getAdConversion() + this.alpha_conv;
+            beta_score = this.beta_conversion + adActionFeature.getAdView() - adActionFeature.getAdConversion();
+        }else {
+            AdActionFeature videoAdFeature=this.videoAdActionFeatureMap.getOrDefault(item.getVideoId(),new AdActionFeature());
+            double k=(videoAdFeature.getAdConversion()+videoAdFeature.getAdView())/1000d;
+            double alpha=(videoAdFeature.getAdConversion())/k;
+            alpha_score =adActionFeature.getAdConversion() + alpha;
+            beta_score = 1000d +  adActionFeature.getAdView() -  adActionFeature.getAdConversion();
         }
-        double alpha_cvr = (int) adActionFeature.getAdConversion() + 10d;
-        double beta_cvr = 100d + (int) adActionFeature.getAdClick() - (int) adActionFeature.getAdConversion();
-        return this.betaSampler(alpha_cvr, beta_cvr);
+        return this.betaSampler(alpha_score, beta_score);
     }
 
     public double score(AdRankItem item) {
@@ -147,7 +163,6 @@ public class VideoAdThompsonModel extends Model{
             alpha_score =adActionFeature.getAdConversion() + alpha;
             beta_score = 1000d +  adActionFeature.getAdView() -  adActionFeature.getAdConversion();
         }
-
         return this.betaSampler(alpha_score, beta_score);
     }
 

+ 7 - 1
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/VideoAdThompsonScorer.java

@@ -82,16 +82,22 @@ public class VideoAdThompsonScorer extends BaseThompsonSamplingScorer {
 
 
         double pscore = 0.0;
+        double pV500 = 0.0;
+        double pV1000 = 0.0;
         double ecpm = 0.0;
         try {
+             pV500 = model.scoreByView500(item);
+             pV1000 = model.scoreByView1000(item);
+
             pscore = model.score(item);
             ecpm = item.getCpa() * item.getBid1() * item.getBid2() * pscore;
         } catch (Exception e) {
             LOGGER.error("score error for doc={} exception={}", new Object[]{
                     item.getAdId(), ExceptionUtils.getFullStackTrace(e)});
         }
-        item.setEcpm1(ecpm);
         item.setScore(ecpm);
+        item.setTf_ctr(pV500);
+        item.setTf_cvr(pV1000);
         return ecpm;
     }
 

+ 4 - 2
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/impl/RankServiceImpl.java

@@ -243,9 +243,11 @@ public class RankServiceImpl implements RankService {
             object.put("lrsamples",rankResult.get(0).getLrSampleString());
             object.put("dataTime",currentTime.format(timeFormatter));
             object.put("creativeId",rankResult.get(0).getAdId());
-            log.info("svc=videoAdThompsonRank {}", JSONObject.toJSONString(object));
+            log.info("svc=videoAdThompsonRank_lr_log {}", JSONObject.toJSONString(object));
             object.remove("lrsamples");
-            log.info("svc=videoAdThompsonRank obj={}", JSONObject.toJSONString(object));
+            object.put("score_500",rankResult.get(0).getTf_ctr());
+            object.put("score_1000",rankResult.get(0).getTf_cvr());
+            log.info("svc=videoAdThompsonRank_log obj={}", JSONObject.toJSONString(object));
             return rankResult.get(0);
         }else {
             //空返回值