Browse Source

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

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

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

@@ -25,18 +25,15 @@ public class RandomPredictModel extends ThresholdPredictModel {
         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());
+
+        String keySuffix = modelParam.getUserExtraFuture("shareType").toString().replace("return", "").replace("mids", "");
+        Integer appType = modelParam.getAppType();
+
+        double threshold = Double.parseDouble(modelParam.getExtraParam().getOrDefault(appType + "_" + keySuffix, -1).toString());
+        if (threshold < 0d) {
+            threshold = Double.parseDouble(modelParam.getExtraParam().getOrDefault("default_" + keySuffix, "-1").toString());
         }
-        double correction=Double.parseDouble(
-                modelParam.getExtraParam()
-                        .getOrDefault("E620_"+modelParam.getAppType()+"_"+DateUtils.getCurrentHour(),1
-                ).toString());
+        double correction = Double.parseDouble(modelParam.getExtraParam().getOrDefault("E620_" + appType + "_" + DateUtils.getCurrentHour(), 1).toString());
         threshold=threshold*correction;
         Map<String, Object> result = new HashMap<>();
         result.put("ad_predict", score<threshold?2:1);