Преглед на файлове

feat:添加人群选择实验

zhaohaipeng преди 4 месеца
родител
ревизия
d8b96eb0cd

+ 3 - 1
.gitignore

@@ -37,4 +37,6 @@ weblog
 logs
 LOG_PATH_IS_UNDEFINED
 
-xgboost
+xgboost
+xgboost351
+word2vec.bin

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

@@ -144,6 +144,12 @@ public class PredictModelServiceImpl implements PredictModelService {
                 result.put("no_ad_strategy", "no_ad_time_with_fixed_time");
                 return result;
             }
+
+
+            if (AbUtil.isInAbExp(expCodes, requestParam.getAppType(), requestParam.getNewExpGroup(), "713")){
+                return predictServiceV2.adPredict(ConvertUtil.predictParam2Context(requestParam));
+            }
+
             String abtestId = null;
             String abTestConfigTag = null;
             Map<String, Object> abtestParam = null;
@@ -225,10 +231,6 @@ public class PredictModelServiceImpl implements PredictModelService {
                 }
             }
 
-            if (AbUtil.isInAbExp(expCodes, requestParam.getAppType(), requestParam.getNewExpGroup(), "713")){
-                return predictServiceV2.adPredict(ConvertUtil.predictParam2Context(requestParam));
-            }
-
             // 市-中文
             requestParam.setRegion(requestParam.getRegion().replace("省", ""));
             requestParam.setCity(requestParam.getCity().replace("市", ""));

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

@@ -29,21 +29,18 @@ public class PredictServiceV2 {
 
         Feature feature = featureService.getPredictFeature(context.getMid());
         Map<String, Map<String, String>> userFeature = feature.getUserFeature();
-
         Map<String, String> featureMap = userFeature.getOrDefault("alg_ad_crowd_choose_feature", new HashMap<>());
 
-        boolean isShowAd = false;
-
-        context.getLogParam().setExpId("713");
+        double score = -1;
 
         // 没有特征为新用户,随机出广告
         if (MapUtils.isEmpty(featureMap)) {
             double newUserShowAdRate = exp713Config.getOrDefault("newUserShowAdRate", 1d);
             double randomRate = Math.random();
             if (randomRate < newUserShowAdRate) {
-                isShowAd = true;
                 context.getLogParam().getScoreMap().put("newUserShowAdRate", newUserShowAdRate);
                 context.getLogParam().getScoreMap().put("randomRate", randomRate);
+                score = 0;
             }
         } else {
             context.getLogParam().getMetaFeature().putAll(userFeature);
@@ -67,27 +64,27 @@ public class PredictServiceV2 {
             double returnDivShare = NumUtil.div((showAdNewReturnPv + noShowAdNewReturnPv + 1), (showAdSharePv + noShowAdSharePv + 1));
 
             double alpha = exp713Config.getOrDefault("alpha", 0.1d);
-            double score = singleReturnAdIncome + ((showAdShareRate - noShowAdShareRate) * returnDivShare * alpha);
+            score = singleReturnAdIncome + ((showAdShareRate - noShowAdShareRate) * returnDivShare * alpha);
 
-            double showAdScoreThreshold = exp713Config.getOrDefault("showAdScoreThreshold", 0d);
-            if (score >= showAdScoreThreshold) {
-                isShowAd = true;
-            }
 
             context.getLogParam().getScoreMap().put("singleReturnAdIncome", singleReturnAdIncome);
             context.getLogParam().getScoreMap().put("showAdShareRate", showAdShareRate);
             context.getLogParam().getScoreMap().put("noShowAdShareRate", noShowAdShareRate);
             context.getLogParam().getScoreMap().put("returnDivShare", returnDivShare);
-            context.getLogParam().getScoreMap().put("score", score);
             context.getLogParam().getScoreMap().put("alpha", alpha);
-            context.getLogParam().getScoreMap().put("showAdScoreThreshold", showAdScoreThreshold);
-            context.getLogParam().setScore(score);
 
         }
+        double showAdScoreThreshold = exp713Config.getOrDefault("showAdScoreThreshold", 0d);
+
+        context.getLogParam().setExpId("713");
+        context.getLogParam().setScore(score);
+        context.getLogParam().getScoreMap().put("score", score);
+        context.getLogParam().getScoreMap().put("showAdScoreThreshold", showAdScoreThreshold);
 
         logHubService.crowdChooseLogUpload(context);
 
-        if (isShowAd) {
+
+        if (score >= showAdScoreThreshold) {
             Map<String, Object> rtnMap = rtnAdPredict();
             rtnMap.putAll(context.getLogParam().getScoreMap());
             return rtnMap;
@@ -105,7 +102,7 @@ public class PredictServiceV2 {
 
     private Map<String, Object> rtnAdPredict() {
         Map<String, Object> rtnMap = new HashMap<>();
-        rtnMap.put("ad_predict", 1);
+        rtnMap.put("ad_predict", 2);
         return rtnMap;
     }
 }