|
@@ -41,6 +41,13 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
|
|
|
private Map<String, Double> bucketsLen = new HashMap<>();
|
|
|
|
|
|
+ private static final Long feibianCustomerId = 13L;
|
|
|
+
|
|
|
+ private static final Long yuanwanCustomerId = 70L;
|
|
|
+
|
|
|
+ @Value("${swap.exp:770}")
|
|
|
+ protected String swapExp;
|
|
|
+
|
|
|
@Value("${word2vec.exp:694}")
|
|
|
private String word2vecExp;
|
|
|
|
|
@@ -92,6 +99,12 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
|
|
|
Map<String, String> userFeatureMap = new HashMap<>();
|
|
|
Map<String, String> c1Feature = userFeature.getOrDefault("alg_mid_feature_ad_action", new HashMap<>());
|
|
|
+ boolean targetCrowd = false;
|
|
|
+ if (c1Feature.containsKey("user_conver_ad_class") && StringUtils.isNotEmpty(c1Feature.get("user_conver_ad_class"))) {
|
|
|
+ if (c1Feature.get("user_conver_ad_class").contains("中医")) {
|
|
|
+ targetCrowd = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
List<TupleMapEntry<Tuple5>> midActionList = this.handleC1Feature(c1Feature, userFeatureMap);
|
|
|
|
|
|
Map<String, Double> midTimeDiffMap = this.parseC1FeatureListToTimeDiffMap(midActionList, ts);
|
|
@@ -156,6 +169,7 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
adRankItem.setCampaignId(dto.getCampaignId());
|
|
|
adRankItem.setCpm(ObjUtil.nullOrDefault(dto.getCpm(), 90).doubleValue());
|
|
|
adRankItem.setSkuId(dto.getSkuId());
|
|
|
+ adRankItem.setCustomerId(dto.getCustomerId());
|
|
|
adRankItem.setRandom(random.nextInt(1000));
|
|
|
if (noApiAdVerIds.contains(dto.getAdVerId())) {
|
|
|
adRankItem.getExt().put("isApi", "0");
|
|
@@ -271,7 +285,13 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
double calibratedScore = originalScore / (originalScore + (1 - originalScore) / negSampleRate);
|
|
|
// 该创意尚未在模型中训练,打分不可靠
|
|
|
if (CollectionUtils.isNotEmpty(DnnCidDataHelper.getCidSet()) && !DnnCidDataHelper.getCidSet().contains(item.getAdId())) {
|
|
|
- log.info("not cid calibratedScore={}, cid={}", calibratedScore, item.getAdId());
|
|
|
+ Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(String.valueOf(item.getAdId()), new HashMap<>());
|
|
|
+ Map<String, String> b3Feature = cidFeature.getOrDefault("alg_cid_feature_cid_action", new HashMap<>());
|
|
|
+ double view = Double.parseDouble(b3Feature.getOrDefault("ad_view_14d", "0"));
|
|
|
+ double conver = Double.parseDouble(b3Feature.getOrDefault("ad_conversion_14d", "0"));
|
|
|
+ double smoothCxr = NumUtil.divSmoothV1(conver, view, 1.64);
|
|
|
+ //模型打分和统计计算取打分更低的
|
|
|
+ calibratedScore = Math.min(smoothCxr, calibratedScore);
|
|
|
}
|
|
|
item.setLrScore(calibratedScore);
|
|
|
item.getScoreMap().put("originCtcvrScore", originalScore);
|
|
@@ -302,6 +322,28 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
|
|
|
|
|
|
result.sort(ComparatorUtil.equalsRandomComparator());
|
|
|
+ if (scoreParam.getExpCodeSet().contains(swapExp) && targetCrowd) {
|
|
|
+ AdRankItem top1Item = result.get(0);
|
|
|
+ // 确定要查找的目标客户ID
|
|
|
+ Long targetCustomerId = null;
|
|
|
+ if (Objects.equals(top1Item.getCustomerId(), feibianCustomerId)) {
|
|
|
+ targetCustomerId = yuanwanCustomerId;
|
|
|
+ } else if (Objects.equals(top1Item.getCustomerId(), yuanwanCustomerId)) {
|
|
|
+ targetCustomerId = feibianCustomerId;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果需要交换,查找目标ID并交换位置
|
|
|
+ if (targetCustomerId != null) {
|
|
|
+ for (int i = 1; i < result.size(); i++) {
|
|
|
+ AdRankItem adRankItem = result.get(i);
|
|
|
+ if (adRankItem != null && Objects.equals(adRankItem.getCustomerId(), targetCustomerId)) {
|
|
|
+ log.info("swapExp source={} target={}, mid={}", result.get(0), result.get(i), request.getMid());
|
|
|
+ Collections.swap(result, 0, i);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result)) {
|
|
|
AdRankItem top1Item = result.get(0);
|