فهرست منبع

Merge branch 'feature_20250728_add_log' of algorithm/ad-engine into master

zhaohaipeng 1 روز پیش
والد
کامیت
a7fa042514

+ 26 - 11
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/model/threshold/RandomPredict667Model.java

@@ -1,5 +1,7 @@
 package com.tzld.piaoquan.ad.engine.service.predict.model.threshold;
 
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.ad.engine.commons.util.JSONUtils;
 import com.tzld.piaoquan.ad.engine.service.predict.container.RandWContainer;
 import com.tzld.piaoquan.ad.engine.service.predict.param.ThresholdPredictModelParam;
 import org.slf4j.Logger;
@@ -21,23 +23,36 @@ public class RandomPredict667Model extends ThresholdPredictModel {
 
     @Override
     public Map<String, Object> predict(ThresholdPredictModelParam modelParam) {
-        int hash=modelParam.getMid().hashCode();
-        hash=hash<0?-hash:hash;
-        double score=(hash+ RandWContainer.getRandW())%100/100d;
-        double threshold=Double.parseDouble(
-                modelParam.getExtraParam().getOrDefault(modelParam.getAppType()+"_"+modelParam.getUserExtraFuture("shareType").toString().replace("return","").replace("mids",""),-1
-                ).toString());
-        if(threshold<0d){
-            threshold=Double.parseDouble(
-                    modelParam.getExtraParam().getOrDefault("default_threshold","0.5")
-                    .toString());
+        int hash = modelParam.getMid().hashCode();
+        hash = hash < 0 ? -hash : hash;
+        double score = (hash + RandWContainer.getRandW()) % 100 / 100d;
+
+        String thresholdParamKey = modelParam.getAppType() + "_" + modelParam.getUserExtraFuture("shareType").toString().replace("return", "").replace("mids", "");
+
+        double threshold = Double.parseDouble(modelParam.getExtraParam().getOrDefault(thresholdParamKey, -1).toString());
+
+        if (threshold < 0d) {
+            thresholdParamKey = "default_threshold";
+            threshold = Double.parseDouble(modelParam.getExtraParam().getOrDefault(thresholdParamKey, "0.5").toString());
         }
         Map<String, Object> result = new HashMap<>();
-        result.put("ad_predict", score<threshold?2:1);
+        result.put("ad_predict", score < threshold ? 2 : 1);
         result.put("score", score);
         result.put("threshold", threshold);
         result.put("model", initName());
 
+        JSONObject logJson = new JSONObject();
+        logJson.putAll(result);
+        logJson.put("mid", modelParam.getMid());
+        logJson.put("expId", "667");
+        logJson.put("appType", modelParam.getAppType());
+        logJson.put("thresholdParamKey", thresholdParamKey);
+        logJson.put("adPlatformType", modelParam.getAdPlatformType());
+        logJson.put("abCode", modelParam.getAbTestCode());
+
+        log.info("广告跳出选择 -- 667实验结果: {}, 参数: {}",
+                JSONUtils.toJson(result), logJson.toJSONString());
+
         return result;
     }
 

+ 1 - 0
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/model/threshold/RandomPredictModel.java

@@ -55,6 +55,7 @@ public class RandomPredictModel extends ThresholdPredictModel {
         logJson.put("appType", appType);
         logJson.put("thresholdParamKey", thresholdParamKey);
         logJson.put("adPlatformType", modelParam.getAdPlatformType());
+        logJson.put("abCode", modelParam.getAbTestCode());
 
         log.info("广告跳出选择 -- 599实验结果: {}, 参数: {}",
                 JSONUtils.toJson(result), logJson.toJSONString());