|
@@ -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;
|
|
|
}
|
|
|
}
|