Pārlūkot izejas kodu

Merge branch '20260715_feature_fjy_copc_v3_c1' of algorithm/ad-engine into master

fanjinyang 1 nedēļu atpakaļ
vecāks
revīzija
08e05a02f6

+ 43 - 22
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy865.java

@@ -1120,34 +1120,55 @@ public class RankStrategyBy865 extends RankStrategyBasic {
                                      double minValid, double maxValid,
                                      double minVal, double maxVal) {
         try {
-            String layer = reqFeature.get("layer_l4");
             if (Boolean.TRUE.equals(copcV3Enabled)) {
-                for (AdRankItem item : items) {
-                    Double coefficient = CopcV3DataHelper.getLandingCoefficient(item.getLrScore(),
-                            item.getLandingPageType(), item.getTargetingConversion());
-//                    log.info("CopcV3DataHelper originScore={}, pageType={},target={},result={}",item.getLrScore(), item.getLandingPageType(),item.getTargetingConversion(),coefficient);
-                    if (coefficient != null) {
-                        double ctcvr = item.getLrScore() * coefficient;
-                        item.getScoreMap().put("copcV3Coefficient", coefficient);
+                calibrationCidCtcvrV2(items, modelName, reqFeature, minValid, maxValid, minVal, maxVal);
+                return;
+            }
+            for (AdRankItem item : items) {
+                Double coefficient = CopcV3DataHelper.getLandingCoefficient(item.getLrScore(),
+                        item.getLandingPageType(), item.getTargetingConversion());
+                if (coefficient != null) {
+                    double ctcvr = item.getLrScore() * coefficient;
+                    item.getScoreMap().put("copcV3Coefficient", coefficient);
+                    item.getScoreMap().put("cidCtcvrScore", ctcvr);
+                    item.getScoreMap().put("ctcvrScore", ctcvr);
+                    item.setLrScore(ctcvr);
+                }
+            }
+        } catch (Exception e) {
+            log.error("calibCidScore error", e);
+        }
+    }
+
+
+    private void calibrationCidCtcvrV2(List<AdRankItem> items, String modelName, Map<String, String> reqFeature,
+                                     double minValid, double maxValid,
+                                     double minVal, double maxVal) {
+        try {
+            String layer = reqFeature.get("layer_l4");
+            for (AdRankItem item : items) {
+                String cid = String.valueOf(item.getAdId());
+                Double diff = CreativeUserLayerDataHelperV2.getCopc(modelName, cid, layer);
+                if (null != diff) {
+                    double newDiff = Math.min(Math.max(minVal, diff), maxVal);
+                    if (newDiff < minValid || newDiff > maxValid) {
+                        double ctcvr = item.getLrScore() * newDiff;
                         item.getScoreMap().put("cidCtcvrScore", ctcvr);
                         item.getScoreMap().put("ctcvrScore", ctcvr);
+                        item.getScoreMap().put("copcV2Coefficient", newDiff);
                         item.setLrScore(ctcvr);
                     }
+                    continue;
                 }
-            }else {
-                for (AdRankItem item : items) {
-                    String cid = String.valueOf(item.getAdId());
-                    Double diff = CreativeUserLayerDataHelperV2.getCopc(modelName, cid, layer);
-                    if (null != diff) {
-                        double newDiff = Math.min(Math.max(minVal, diff), maxVal);
-                        if (newDiff < minValid || newDiff > maxValid) {
-                            double ctcvr = item.getLrScore() * newDiff;
-                            item.getScoreMap().put("cidCtcvrScore", ctcvr);
-                            item.getScoreMap().put("ctcvrScore", ctcvr);
-                            item.getScoreMap().put("copcDiff", diff);
-                            item.setLrScore(ctcvr);
-                        }
-                    }
+
+                Double coefficient = CopcV3DataHelper.getLandingCoefficient(item.getLrScore(),
+                        item.getLandingPageType(), item.getTargetingConversion());
+                if (coefficient != null) {
+                    double ctcvr = item.getLrScore() * coefficient;
+                    item.getScoreMap().put("copcV3Coefficient", coefficient);
+                    item.getScoreMap().put("cidCtcvrScore", ctcvr);
+                    item.getScoreMap().put("ctcvrScore", ctcvr);
+                    item.setLrScore(ctcvr);
                 }
             }
         } catch (Exception e) {