Browse Source

feat:修改版本

zhaohaipeng 10 tháng trước cách đây
mục cha
commit
f4bf1a4d44

+ 0 - 2
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/impl/PredictModelServiceImpl.java

@@ -231,7 +231,6 @@ public class PredictModelServiceImpl implements PredictModelService {
                 result = ThresholdModelContainer.getThresholdPredictModel("random673").predict(modelParam);
                 // 如果676实验返回结果,表示未命中规则即对应的用户来源和所属层存在配置,使用676实验的结果,否则继续走599实验
                 if (Objects.nonNull(result)) {
-                    log.info("广告跳出选择 -- 673实验结果: {}", JSONUtils.toJson(result));
                     return result;
                 }
             }
@@ -244,7 +243,6 @@ public class PredictModelServiceImpl implements PredictModelService {
                 result = ThresholdModelContainer.
                         getThresholdPredictModel("random")
                         .predict(modelParam);
-                log.info("广告跳出选择 -- 599实验结果: {}", JSONUtils.toJson(result));
             } else if (expCodes.contains("667") ||
                     (expCodes.contains(NewExpInfoHelper.flagId) && NewExpInfoHelper.checkInNewExpGroupAndSetParamIfIn(
                             requestParam.getAppType().toString(), requestParam.getNewExpGroup(), "667", modelParam))) {

+ 9 - 2
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/model/threshold/RandomPredict673Model.java

@@ -1,5 +1,6 @@
 package com.tzld.piaoquan.ad.engine.service.predict.model.threshold;
 
+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.apache.commons.lang3.StringUtils;
@@ -51,9 +52,12 @@ public class RandomPredict673Model extends ThresholdPredictModel {
                 .replace("mids", "");
         Integer appType = modelParam.getAppType();
 
-        double threshold = Double.parseDouble(abParam.getOrDefault(appType + "_" + keySuffix, -1).toString());
+        String thresholdParamKey = appType + "_" + keySuffix;
+
+        double threshold = Double.parseDouble(abParam.getOrDefault(thresholdParamKey, -1).toString());
         if (threshold < 0d) {
-            threshold = Double.parseDouble(abParam.getOrDefault("default_" + keySuffix, "-1").toString());
+            thresholdParamKey = "default_" + keySuffix;
+            threshold = Double.parseDouble(abParam.getOrDefault(thresholdParamKey, "-1").toString());
         }
         Map<String, Object> result = new HashMap<>();
         result.put("ad_predict", score < threshold ? 2 : 1);
@@ -61,6 +65,9 @@ public class RandomPredict673Model extends ThresholdPredictModel {
         result.put("threshold", threshold);
         result.put("model", this.initName());
 
+        log.info("广告跳出选择 -- 673实验结果: {}, 参数: {}, {}, {}, {}",
+                JSONUtils.toJson(result), appType, modelParam.getMid(), abParamKey, thresholdParamKey);
+
         return result;
     }
 

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

@@ -1,6 +1,7 @@
 package com.tzld.piaoquan.ad.engine.service.predict.model.threshold;
 
 import com.tzld.piaoquan.ad.engine.commons.util.DateUtils;
+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;
@@ -22,25 +23,31 @@ public class RandomPredictModel 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;
+        int hash = modelParam.getMid().hashCode();
+        hash = hash < 0 ? -hash : hash;
+        double score = (hash + RandWContainer.getRandW()) % 100 / 100d;
+
+        String keySuffix = modelParam.getUserExtraFuture("shareType").toString()
+                .replace("return", "")
+                .replace("mids", "");
 
-        String keySuffix = modelParam.getUserExtraFuture("shareType").toString().replace("return", "").replace("mids", "");
         Integer appType = modelParam.getAppType();
+        String thresholdParamKey = appType + "_" + keySuffix;
 
-        double threshold = Double.parseDouble(modelParam.getExtraParam().getOrDefault(appType + "_" + keySuffix, -1).toString());
+        double threshold = Double.parseDouble(modelParam.getExtraParam().getOrDefault(thresholdParamKey, -1).toString());
         if (threshold < 0d) {
-            threshold = Double.parseDouble(modelParam.getExtraParam().getOrDefault("default_" + keySuffix, "-1").toString());
+            thresholdParamKey = "default_" + keySuffix;
+            threshold = Double.parseDouble(modelParam.getExtraParam().getOrDefault(thresholdParamKey, "-1").toString());
         }
         double correction = Double.parseDouble(modelParam.getExtraParam().getOrDefault("E620_" + appType + "_" + DateUtils.getCurrentHour(), 1).toString());
-        threshold=threshold*correction;
+        threshold = threshold * correction;
         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", "random");
-
+        log.info("广告跳出选择 -- 599实验结果: {}, 参数: {}, {}, {}",
+                JSONUtils.toJson(result), appType, modelParam.getMid(), thresholdParamKey);
         return result;
     }