Browse Source

feat:人群选择添加rootSessionId尾号实验机制

zhaohaipeng 2 days ago
parent
commit
162966b51b

+ 6 - 4
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/v2/BasicPredict.java

@@ -5,19 +5,21 @@ import java.util.Map;
 
 public abstract class BasicPredict {
 
-    public abstract Map<String, Object> predict(PredictContext context);
+    public abstract Map<String, Object> predict(PredictContext ctx);
 
-    protected Map<String, Object> rtnNoAdPredict(PredictContext context) {
+    protected Map<String, Object> rtnNoAdPredict(PredictContext ctx) {
         Map<String, Object> rtnMap = new HashMap<>();
         rtnMap.put("ad_predict", 1);
         rtnMap.put("no_ad_strategy", "713_exp");
+        rtnMap.put("pqtId", ctx.getPqtId());
         return rtnMap;
     }
 
-    protected Map<String, Object> rtnAdPredict(PredictContext context) {
+    protected Map<String, Object> rtnAdPredict(PredictContext ctx) {
         Map<String, Object> rtnMap = new HashMap<>();
         rtnMap.put("ad_predict", 2);
-        rtnMap.putAll(context.getLogParam().getScoreMap());
+        rtnMap.putAll(ctx.getLogParam().getScoreMap());
+        rtnMap.put("pqtId", ctx.getPqtId());
         return rtnMap;
     }
 }

+ 26 - 26
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/v2/PredictServiceV2.java

@@ -23,15 +23,15 @@ public class PredictServiceV2 extends BasicPredict {
     private Map<String, Double> exp713Config;
 
     @Override
-    public Map<String, Object> predict(PredictContext context) {
-        Feature feature = featureService.getPredictFeature(context);
+    public Map<String, Object> predict(PredictContext ctx) {
+        Feature feature = featureService.getPredictFeature(ctx);
         Map<String, Map<String, String>> userFeature = feature.getUserFeature();
         Map<String, String> featureMap = userFeature.getOrDefault("alg_ad_crowd_choose_feature_v2", new HashMap<>());
         double minScore = exp713Config.getOrDefault("minScore", 0.1d);
         double maxScore = exp713Config.getOrDefault("maxScore", 0.8d);
         double score = maxScore;
 
-        context.getLogParam().setBIsNewUser(true);
+        ctx.getLogParam().setBIsNewUser(true);
 
         if (MapUtils.isNotEmpty(featureMap)) {
 
@@ -63,23 +63,23 @@ public class PredictServiceV2 extends BasicPredict {
             score = NumUtil.softmax(new double[]{hasAdValue * hasRate, noAdValue * noRate})[0];
 
 
-            context.getLogParam().getMetaFeature().putAll(feature.getUserFeature());
+            ctx.getLogParam().getMetaFeature().putAll(feature.getUserFeature());
             for (Map.Entry<String, String> entry : featureMap.entrySet()) {
-                context.getLogParam().getAllFeature().put(entry.getKey(), Double.parseDouble(entry.getValue()));
+                ctx.getLogParam().getAllFeature().put(entry.getKey(), Double.parseDouble(entry.getValue()));
             }
-            context.getLogParam().getScoreMap().put("adClickValue", NumUtil.round(adClickValue, 6));
-            context.getLogParam().getScoreMap().put("adConverValue", NumUtil.round(adConverValue, 6));
-            context.getLogParam().getScoreMap().put("hasAdShareValue", NumUtil.round(hasAdShareValue, 6));
-            context.getLogParam().getScoreMap().put("hasAdReturnValue", NumUtil.round(hasAdReturnValue, 6));
-            context.getLogParam().getScoreMap().put("hasAdValue", NumUtil.round(hasAdValue, 6));
-            context.getLogParam().getScoreMap().put("noAdShareValue", NumUtil.round(noAdShareValue, 6));
-            context.getLogParam().getScoreMap().put("noAdReturnValue", NumUtil.round(noAdReturnValue, 6));
-            context.getLogParam().getScoreMap().put("noAdValue", NumUtil.round(noAdValue, 6));
-            context.getLogParam().getScoreMap().put("originScore", NumUtil.round(score, 6));
-            context.getLogParam().getScoreMap().put("hasRate", NumUtil.round(hasRate, 6));
-            context.getLogParam().getScoreMap().put("noRate", NumUtil.round(noRate, 6));
-
-            context.getLogParam().setBIsNewUser(false);
+            ctx.getLogParam().getScoreMap().put("adClickValue", NumUtil.round(adClickValue, 6));
+            ctx.getLogParam().getScoreMap().put("adConverValue", NumUtil.round(adConverValue, 6));
+            ctx.getLogParam().getScoreMap().put("hasAdShareValue", NumUtil.round(hasAdShareValue, 6));
+            ctx.getLogParam().getScoreMap().put("hasAdReturnValue", NumUtil.round(hasAdReturnValue, 6));
+            ctx.getLogParam().getScoreMap().put("hasAdValue", NumUtil.round(hasAdValue, 6));
+            ctx.getLogParam().getScoreMap().put("noAdShareValue", NumUtil.round(noAdShareValue, 6));
+            ctx.getLogParam().getScoreMap().put("noAdReturnValue", NumUtil.round(noAdReturnValue, 6));
+            ctx.getLogParam().getScoreMap().put("noAdValue", NumUtil.round(noAdValue, 6));
+            ctx.getLogParam().getScoreMap().put("originScore", NumUtil.round(score, 6));
+            ctx.getLogParam().getScoreMap().put("hasRate", NumUtil.round(hasRate, 6));
+            ctx.getLogParam().getScoreMap().put("noRate", NumUtil.round(noRate, 6));
+
+            ctx.getLogParam().setBIsNewUser(false);
         }
 
         // 分数截断,避免过长或过短
@@ -91,16 +91,16 @@ public class PredictServiceV2 extends BasicPredict {
 
         double random = Math.random();
         boolean isShowAd = random < score;
-        context.getLogParam().setExpId("713");
-        context.getLogParam().setScore(score);
-        context.getLogParam().getScoreMap().put("score", NumUtil.round(score, 6));
-        context.getLogParam().setAIsShowAd(isShowAd);
-        context.getLogParam().getScoreMap().put("minScore", minScore);
-        context.getLogParam().getScoreMap().put("maxScore", maxScore);
-        context.getLogParam().getScoreMap().put("random", random);
+        ctx.getLogParam().setExpId("713");
+        ctx.getLogParam().setScore(score);
+        ctx.getLogParam().getScoreMap().put("score", NumUtil.round(score, 6));
+        ctx.getLogParam().setAIsShowAd(isShowAd);
+        ctx.getLogParam().getScoreMap().put("minScore", minScore);
+        ctx.getLogParam().getScoreMap().put("maxScore", maxScore);
+        ctx.getLogParam().getScoreMap().put("random", random);
 
 
-        return isShowAd ? rtnAdPredict(context) : rtnNoAdPredict(context);
+        return isShowAd ? rtnAdPredict(ctx) : rtnNoAdPredict(ctx);
     }