|
@@ -2,6 +2,9 @@ package com.tzld.piaoquan.ad.engine.service.score.strategy;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
+import com.tzld.piaoquan.ad.engine.commons.dto.AdPlatformCreativeDTO;
|
|
|
+import com.tzld.piaoquan.ad.engine.commons.helper.DnnCidDataHelper;
|
|
|
+import com.tzld.piaoquan.ad.engine.commons.param.RankRecommendRequestParam;
|
|
|
import com.tzld.piaoquan.ad.engine.commons.score.ScoreParam;
|
|
|
import com.tzld.piaoquan.ad.engine.commons.score.ScorerUtils;
|
|
|
import com.tzld.piaoquan.ad.engine.commons.thread.ThreadPoolFactory;
|
|
@@ -9,8 +12,6 @@ import com.tzld.piaoquan.ad.engine.commons.util.*;
|
|
|
import com.tzld.piaoquan.ad.engine.service.entity.CorrectCpaParam;
|
|
|
import com.tzld.piaoquan.ad.engine.service.entity.GuaranteeView;
|
|
|
import com.tzld.piaoquan.ad.engine.service.feature.Feature;
|
|
|
-import com.tzld.piaoquan.ad.engine.commons.dto.AdPlatformCreativeDTO;
|
|
|
-import com.tzld.piaoquan.ad.engine.commons.param.RankRecommendRequestParam;
|
|
|
import com.tzld.piaoquan.recommend.feature.domain.ad.base.AdRankItem;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -45,21 +46,33 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
@Value("${word2vec.exp:694}")
|
|
|
private String word2vecExp;
|
|
|
|
|
|
+
|
|
|
// FIXME(zhoutian): 可能需要独立配置
|
|
|
@ApolloJsonValue("${rank.score.weight.680:{}}")
|
|
|
private Map<String, Double> weightMap;
|
|
|
|
|
|
+ /**
|
|
|
+ * 人群分层&创意的权重
|
|
|
+ * 格式:{layer_creativeId: weight}
|
|
|
+ */
|
|
|
+ @ApolloJsonValue("${rank.score.weight.layer.and.creative:{}}")
|
|
|
+ private Map<String, Double> layerAndCreativeWeightMap;
|
|
|
+
|
|
|
@ApolloJsonValue("${rank.score.neg_sample_rate:0.01}")
|
|
|
Double negSampleRate;
|
|
|
|
|
|
+ Set<String> sparseFeatureSet;
|
|
|
+
|
|
|
+
|
|
|
@PostConstruct
|
|
|
public void afterInit() {
|
|
|
this.readBucketFile();
|
|
|
+ this.initSparseFeatureNames();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public List<AdRankItem> adItemRank(RankRecommendRequestParam request, ScoreParam scoreParam) {
|
|
|
-
|
|
|
Map<String, Double> weightParam = ObjUtil.nullOrDefault(weightMap, new HashMap<>());
|
|
|
|
|
|
|
|
@@ -80,6 +93,7 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
// feature1
|
|
|
Feature feature = this.getFeature(scoreParam, request);
|
|
|
|
|
|
+
|
|
|
Map<String, Map<String, String>> userFeature = feature.getUserFeature();
|
|
|
Map<String, Map<String, String>> videoFeature = feature.getVideoFeature();
|
|
|
Map<String, Map<String, Map<String, String>>> allAdVerFeature = feature.getAdVerFeature();
|
|
@@ -87,7 +101,6 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
Map<String, Map<String, Map<String, String>>> allSkuFeature = feature.getSkuFeature();
|
|
|
Map<String, String> reqFeature = this.getReqFeature(scoreParam, request);
|
|
|
|
|
|
-
|
|
|
Map<String, String> userFeatureMap = new HashMap<>();
|
|
|
Map<String, String> c1Feature = userFeature.getOrDefault("alg_mid_feature_ad_action", new HashMap<>());
|
|
|
List<TupleMapEntry<Tuple5>> midActionList = this.handleC1Feature(c1Feature, userFeatureMap);
|
|
@@ -103,6 +116,37 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
Map<String, String> e1Feature = userFeature.getOrDefault("alg_mid_feature_return_tags", new HashMap<>());
|
|
|
Map<String, String> e2Feature = userFeature.getOrDefault("alg_mid_feature_share_tags", new HashMap<>());
|
|
|
|
|
|
+ Map<String, String> g1Feature = userFeature.getOrDefault("mid_return_video_cate", new HashMap<>());
|
|
|
+ Map<String, String> g2Feature = userFeature.getOrDefault("mid_share_video_cate", new HashMap<>());
|
|
|
+
|
|
|
+
|
|
|
+ userFeatureMap.put("brand", reqFeature.getOrDefault("brand", ""));
|
|
|
+ userFeatureMap.put("region", reqFeature.getOrDefault("region", ""));
|
|
|
+ userFeatureMap.put("city", reqFeature.getOrDefault("city", ""));
|
|
|
+ userFeatureMap.put("vid", reqFeature.getOrDefault("vid", ""));
|
|
|
+ userFeatureMap.put("apptype", reqFeature.getOrDefault("apptype", ""));
|
|
|
+ userFeatureMap.put("is_first_layer", reqFeature.getOrDefault("is_first_layer", ""));
|
|
|
+ userFeatureMap.put("root_source_scene", reqFeature.getOrDefault("root_source_scene", ""));
|
|
|
+ userFeatureMap.put("root_source_channel", reqFeature.getOrDefault("root_source_channel", ""));
|
|
|
+
|
|
|
+
|
|
|
+ userFeatureMap.put("cate1", d3Feature.get("merge_first_level_cate"));
|
|
|
+ userFeatureMap.put("cate2", d3Feature.get("merge_second_level_cate"));
|
|
|
+ userFeatureMap.put("user_vid_return_tags_2h", e1Feature.getOrDefault("tags_2h", null));
|
|
|
+ userFeatureMap.put("user_vid_return_tags_1d", e1Feature.getOrDefault("tags_1d", null));
|
|
|
+ userFeatureMap.put("user_vid_return_tags_3d", e1Feature.getOrDefault("tags_3d", null));
|
|
|
+ userFeatureMap.put("user_vid_return_tags_7d", e1Feature.getOrDefault("tags_7d", null));
|
|
|
+ userFeatureMap.put("user_vid_return_tags_14d", e1Feature.getOrDefault("tags_14d", null));
|
|
|
+ userFeatureMap.put("title_split", d3Feature.getOrDefault("title_split", null));
|
|
|
+ userFeatureMap.put("user_vid_share_tags_1d", e2Feature.getOrDefault("tags_1d", null));
|
|
|
+ userFeatureMap.put("user_vid_share_tags_14d", e2Feature.getOrDefault("tags_14d", null));
|
|
|
+ userFeatureMap.put("user_vid_return_cate1_14d", g1Feature.getOrDefault("cate1_14d", null));
|
|
|
+ userFeatureMap.put("user_vid_return_cate2_14d", g1Feature.getOrDefault("cate2_14d", null));
|
|
|
+ userFeatureMap.put("user_vid_share_cate1_14d", g2Feature.getOrDefault("cate1_14d", null));
|
|
|
+ userFeatureMap.put("user_vid_share_cate2_14d", g2Feature.getOrDefault("cate2_14d", null));
|
|
|
+
|
|
|
+ userFeatureMap.put("user_layer_class", reqFeature.getOrDefault("user_layer_class", null));
|
|
|
+
|
|
|
Map<String, String> sceneFeatureMap = this.handleSceneFeature(ts);
|
|
|
long time1 = System.currentTimeMillis();
|
|
|
|
|
@@ -133,7 +177,6 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
} else {
|
|
|
adRankItem.getExt().put("isApi", "1");
|
|
|
}
|
|
|
-
|
|
|
adRankItem.getExt().put("recallsources", dto.getRecallSources());
|
|
|
adRankItem.getExt().put("correctCpaMap", JSONObject.toJSONString(correctCpaMap.get(dto.getAdId())));
|
|
|
adRankItem.getExt().put("correctionFactor", correctCpaMap.get(dto.getAdId()).getCorrectionFactor());
|
|
@@ -144,7 +187,7 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
Map<String, String> b1Feature = cidFeature.getOrDefault("alg_cid_feature_basic_info", new HashMap<>());
|
|
|
|
|
|
Map<String, Map<String, String>> adVerFeature = allAdVerFeature.getOrDefault(dto.getAdVerId(), new HashMap<>());
|
|
|
-
|
|
|
+ Map<String, Map<String, String>> skuFeature = allSkuFeature.getOrDefault(String.valueOf(dto.getSkuId()), new HashMap<>());
|
|
|
Map<String, String> d1Feature = cidFeature.getOrDefault("alg_cid_feature_vid_cf", new HashMap<>());
|
|
|
|
|
|
this.handleB1Feature(b1Feature, cidFeatureMap, cidStr);
|
|
@@ -153,6 +196,17 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
this.handleC1UIFeature(midTimeDiffMap, actionStaticMap, cidFeatureMap, cidStr);
|
|
|
this.handleD1Feature(d1Feature, cidFeatureMap);
|
|
|
this.handleD2Feature(vidRankMaps, cidFeatureMap, cidStr);
|
|
|
+ this.handleH1AndH2Feature(skuFeature, adVerFeature, cidFeatureMap);
|
|
|
+ cidFeatureMap.put("cid", dto.getCreativeId() != null ? String.valueOf(dto.getCreativeId()) : "");
|
|
|
+ cidFeatureMap.put("adid", dto.getAdId() != null ? String.valueOf(dto.getAdId()) : "");
|
|
|
+ cidFeatureMap.put("adverid", dto.getAdVerId() != null ? dto.getAdVerId() : "");
|
|
|
+ cidFeatureMap.put("profession", dto.getProfession() != null ? dto.getProfession() : "");
|
|
|
+ //DNN模型没训练过的cid才不传入广告相关的稀疏特征
|
|
|
+ if (CollectionUtils.isNotEmpty(DnnCidDataHelper.getCidSetV2()) && !DnnCidDataHelper.getCidSetV2().contains(adRankItem.getAdId())) {
|
|
|
+ cidFeatureMap.put("cid", "");
|
|
|
+ cidFeatureMap.put("adid", "");
|
|
|
+ cidFeatureMap.put("adverid", "");
|
|
|
+ }
|
|
|
return adRankItem;
|
|
|
} finally {
|
|
|
cdl1.countDown();
|
|
@@ -226,27 +280,38 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
long time4 = System.currentTimeMillis();
|
|
|
// 打分排序
|
|
|
// getScorerPipeline
|
|
|
- List<AdRankItem> result = ScorerUtils.getScorerPipeline(ScorerUtils.XGBOOST_SCORE_CONF_683).scoring(sceneFeatureMap, userFeatureMap, adRankItems);
|
|
|
+ List<AdRankItem> result = ScorerUtils.getScorerPipeline(ScorerUtils.PAI_SCORE_CONF_20250804).scoring(sceneFeatureMap, userFeatureMap, adRankItems);
|
|
|
long time5 = System.currentTimeMillis();
|
|
|
-
|
|
|
- // calibrate score for negative sampling
|
|
|
+ // calibrate score for negative sampling or cold start
|
|
|
for (AdRankItem item : result) {
|
|
|
double originalScore = item.getLrScore();
|
|
|
double calibratedScore = originalScore / (originalScore + (1 - originalScore) / negSampleRate);
|
|
|
+ // 该创意尚未在模型中训练,打分不可靠
|
|
|
+ if (CollectionUtils.isNotEmpty(DnnCidDataHelper.getCidSetV2()) && !DnnCidDataHelper.getCidSetV2().contains(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);
|
|
|
item.getScoreMap().put("modelCtcvrScore", calibratedScore);
|
|
|
item.getScoreMap().put("ctcvrScore", calibratedScore);
|
|
|
}
|
|
|
|
|
|
- calculateCtcvrScore(result, request, scoreParam, null, reqFeature);
|
|
|
+ calculateCtcvrScore(result, request, scoreParam, "dnn", reqFeature);
|
|
|
// loop
|
|
|
double cpmCoefficient = weightParam.getOrDefault("cpmCoefficient", 0.9);
|
|
|
boolean isGuaranteeType = false;
|
|
|
+ // 查询人群分层信息
|
|
|
+ String peopleLayer = Optional.of(reqFeature)
|
|
|
+ .map(f -> f.get("layer"))
|
|
|
+ .map(s -> s.replace("-炸", ""))
|
|
|
+ .orElse(null);
|
|
|
for (AdRankItem item : result) {
|
|
|
- if (isGuaranteedFlow && item.getExt().get("isGuaranteed") != null && (boolean) item.getExt().get("isGuaranteed")) {
|
|
|
- isGuaranteeType = true;
|
|
|
- }
|
|
|
double bid = item.getCpa();
|
|
|
if (scoreParam.getExpCodeSet().contains(correctCpaExp1) || scoreParam.getExpCodeSet().contains(correctCpaExp2)) {
|
|
|
Double correctionFactor = (Double) item.getExt().get("correctionFactor");
|
|
@@ -254,9 +319,16 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
bid = bid * correctionFactor;
|
|
|
}
|
|
|
item.getScoreMap().put("ecpm", item.getLrScore() * bid * 1000);
|
|
|
+ if (isGuaranteedFlow && item.getExt().get("isGuaranteed") != null && (boolean) item.getExt().get("isGuaranteed")) {
|
|
|
+ isGuaranteeType = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ String layerAndCreativeWeightMapKey = getLayerAndCreativeWeightMapKey(peopleLayer, String.valueOf(item.getAdId()));
|
|
|
+ // 人群分层&创意的权重
|
|
|
+ double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
|
|
|
double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
|
|
|
double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
|
|
|
- double score = item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient;
|
|
|
+ double score = item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
|
|
|
item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
|
|
|
item.getScoreMap().put("cpa", item.getCpa());
|
|
|
item.getScoreMap().put("cpm", item.getCpm());
|
|
@@ -265,6 +337,7 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
item.getScoreMap().put("scoreCoefficient", scoreCoefficient);
|
|
|
item.getFeatureMap().putAll(userFeatureMap);
|
|
|
item.getFeatureMap().putAll(sceneFeatureMap);
|
|
|
+
|
|
|
// 没有转化回传的广告主,使用后台配置的CPM
|
|
|
if (noApiAdVerIds.contains(item.getAdVerId())) {
|
|
|
score = item.getCpm() * cpmCoefficient / 1000;
|
|
@@ -277,8 +350,23 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result)) {
|
|
|
AdRankItem top1Item = result.get(0);
|
|
|
+ List<String> participateCompetitionType = new ArrayList<>();
|
|
|
+ participateCompetitionType.add("engine");
|
|
|
top1Item.getExt().put("isGuaranteeType", isGuaranteeType);
|
|
|
+ if (isGuaranteeType) {
|
|
|
+ participateCompetitionType.add("guarantee");
|
|
|
+ }
|
|
|
+ top1Item.getExt().put("participateCompetitionType", StringUtils.join(participateCompetitionType, ","));
|
|
|
+ Double modelCtcvrScore = top1Item.getScoreMap().get("modelCtcvrScore");
|
|
|
+ Double ctcvrScore = top1Item.getScoreMap().get("ctcvrScore");
|
|
|
+ if (scoreParam.getExpCodeSet().contains(checkoutEcpmExp)) {
|
|
|
+ top1Item.getExt().put("ecpm", ctcvrScore * top1Item.getCpa() * 1000);
|
|
|
+ top1Item.getExt().put("filterEcpm", filterEcpm);
|
|
|
+ } else {
|
|
|
+ top1Item.getExt().put("ecpm", modelCtcvrScore * top1Item.getCpa() * 1000);
|
|
|
+ }
|
|
|
putMetaFeature(top1Item, feature, reqFeature, sceneFeatureMap, request);
|
|
|
+ top1Item.getExt().put("model", "dnn");
|
|
|
}
|
|
|
long time6 = System.currentTimeMillis();
|
|
|
log.info("cost={}, getFeature={}, handleFeature={}, similar={}, bucketFeature={}, getScorerPipeline={}, " +
|
|
@@ -289,6 +377,34 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取人群分层和创意的权重
|
|
|
+ *
|
|
|
+ * @param key
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Double getLayerAndCreativeWeight(String key) {
|
|
|
+ if (StringUtils.isBlank(key)) {
|
|
|
+ return 1d;
|
|
|
+ }
|
|
|
+ return layerAndCreativeWeightMap.getOrDefault(key, 1d);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取人群分层和创意的权重key
|
|
|
+ *
|
|
|
+ * @param layer
|
|
|
+ * @param creativeId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getLayerAndCreativeWeightMapKey(String layer, String creativeId) {
|
|
|
+ if (StringUtils.isBlank(layer) || StringUtils.isBlank(creativeId)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return layer + "_" + creativeId;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private void handleB1Feature(Map<String, String> b1Feature, Map<String, String> cidFeatureMap, String cid) {
|
|
|
cidFeatureMap.put("cid_" + cid, "0.1");
|
|
|
// if (StringUtils.isNotBlank(b1Feature.get("adid"))) {
|
|
@@ -389,6 +505,15 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
|
|
|
private List<TupleMapEntry<Tuple5>> handleC1Feature(Map<String, String> c1Feature, Map<String, String> featureMap) {
|
|
|
|
|
|
+ //用户近1年内是否有转化
|
|
|
+ if (c1Feature.containsKey("user_has_conver_1y") && c1Feature.get("user_has_conver_1y") != null) {
|
|
|
+ featureMap.put("user_has_conver_1y", c1Feature.get("user_has_conver_1y"));
|
|
|
+ }
|
|
|
+ //用户历史转化过品类
|
|
|
+ if (c1Feature.containsKey("user_conver_ad_class") && c1Feature.get("user_conver_ad_class") != null) {
|
|
|
+ featureMap.put("user_conver_ad_class", c1Feature.get("user_conver_ad_class"));
|
|
|
+ }
|
|
|
+
|
|
|
// 用户特征
|
|
|
List<TupleMapEntry<Tuple5>> midActionList = new ArrayList<>();
|
|
|
if (c1Feature.containsKey("action")) {
|
|
@@ -416,7 +541,23 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
featureMap.put("ctcvr_all", String.valueOf(NumUtil.div(converAll, viewAll)));
|
|
|
featureMap.put("cvr_all", String.valueOf(NumUtil.div(clickAll, converAll)));
|
|
|
featureMap.put("ecpm_all", String.valueOf(NumUtil.div(incomeAll * 1000, viewAll)));
|
|
|
-
|
|
|
+ if (CollectionUtils.isNotEmpty(midActionList)) {
|
|
|
+ List<String> cidClickList = new ArrayList<>();
|
|
|
+ List<String> cidConverList = new ArrayList<>();
|
|
|
+ for (TupleMapEntry<Tuple5> tupleMapEntry : midActionList) {
|
|
|
+ String cid = tupleMapEntry.key;
|
|
|
+ String click = tupleMapEntry.value.f2;
|
|
|
+ String conver = tupleMapEntry.value.f3;
|
|
|
+ if (Objects.equals(click, "1")) {
|
|
|
+ cidClickList.add(cid);
|
|
|
+ }
|
|
|
+ if (Objects.equals(conver, "1")) {
|
|
|
+ cidConverList.add(cid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ featureMap.put("user_cid_click_list", String.join(",", cidClickList));
|
|
|
+ featureMap.put("user_cid_conver_list", String.join(",", cidConverList));
|
|
|
+ }
|
|
|
return midActionList;
|
|
|
}
|
|
|
|
|
@@ -497,6 +638,33 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void handleH1AndH2Feature(Map<String, Map<String, String>> skuFeature,
|
|
|
+ Map<String, Map<String, String>> adVerFeature,
|
|
|
+ Map<String, String> cidFeatureMap) {
|
|
|
+ Map<String, String> h1Feature = adVerFeature.getOrDefault("alg_mid_feature_adver_action", new HashMap<>());
|
|
|
+ Map<String, String> h2Feature = skuFeature.getOrDefault("alg_mid_feature_sku_action", new HashMap<>());
|
|
|
+ List<String> timeList = Arrays.asList("3d", "7d", "30d");
|
|
|
+ List<Tuple2<Map<String, String>, String>> featureList = Arrays.asList(
|
|
|
+ new Tuple2<>(h1Feature, "adverid"),
|
|
|
+ new Tuple2<>(h2Feature, "skuid")
|
|
|
+ );
|
|
|
+ for (Tuple2<Map<String, String>, String> tuple2 : featureList) {
|
|
|
+ Map<String, String> feature = tuple2.f1;
|
|
|
+ String prefix = tuple2.f2;
|
|
|
+ for (String time : timeList) {
|
|
|
+ String timeValue = feature.getOrDefault(time, "");
|
|
|
+ if (StringUtils.isNotEmpty(timeValue)) {
|
|
|
+ String[] split = timeValue.split(",");
|
|
|
+ cidFeatureMap.put("user" + "_" + prefix + "_" + "view" + "_" + time, split[0]);
|
|
|
+ cidFeatureMap.put("user" + "_" + prefix + "_" + "click" + "_" + time, split[1]);
|
|
|
+ cidFeatureMap.put("user" + "_" + prefix + "_" + "conver" + "_" + time, split[2]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void handleD3AndB1Feature(Map<String, String> d3Feature, String cTitle, Map<String, String> featureMap,
|
|
|
ScoreParam scoreParam) {
|
|
|
if (MapUtils.isEmpty(d3Feature) || !d3Feature.containsKey("title") || StringUtils.isEmpty(cTitle)) {
|
|
@@ -608,7 +776,7 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
}
|
|
|
synchronized (this) {
|
|
|
String bucketFile = "20250217_ad_bucket_688.txt";
|
|
|
- InputStream resourceStream = RankStrategyBy683.class.getClassLoader().getResourceAsStream(bucketFile);
|
|
|
+ InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream(bucketFile);
|
|
|
if (resourceStream != null) {
|
|
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceStream))) {
|
|
|
Map<String, double[]> bucketsMap = new HashMap<>();
|
|
@@ -640,10 +808,72 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void initSparseFeatureNames() {
|
|
|
+ this.sparseFeatureSet = new HashSet<String>() {{
|
|
|
+ add("brand");
|
|
|
+ add("region");
|
|
|
+ add("city");
|
|
|
+ add("vid");
|
|
|
+ add("cate1");
|
|
|
+ add("cate2");
|
|
|
+ add("cid");
|
|
|
+ add("adid");
|
|
|
+ add("adverid");
|
|
|
+ add("user_cid_click_list");
|
|
|
+ add("user_cid_conver_list");
|
|
|
+ add("user_vid_return_tags_2h");
|
|
|
+ add("user_vid_return_tags_1d");
|
|
|
+ add("user_vid_return_tags_3d");
|
|
|
+ add("user_vid_return_tags_7d");
|
|
|
+ add("user_vid_return_tags_14d");
|
|
|
+ add("apptype");
|
|
|
+ add("hour");
|
|
|
+ add("hour_quarter");
|
|
|
+ add("root_source_scene");
|
|
|
+ add("root_source_channel");
|
|
|
+ add("is_first_layer");
|
|
|
+ add("title_split");
|
|
|
+ add("profession");
|
|
|
+ add("user_vid_share_tags_1d");
|
|
|
+ add("user_vid_share_tags_14d");
|
|
|
+ add("user_vid_return_cate1_14d");
|
|
|
+ add("user_vid_return_cate2_14d");
|
|
|
+ add("user_vid_share_cate1_14d");
|
|
|
+ add("user_vid_share_cate2_14d");
|
|
|
+ add("user_has_conver_1y");
|
|
|
+ add("user_conver_ad_class");
|
|
|
+ add("user_adverid_view_3d");
|
|
|
+ add("user_adverid_click_3d");
|
|
|
+ add("user_adverid_conver_3d");
|
|
|
+ add("user_adverid_view_7d");
|
|
|
+ add("user_adverid_click_7d");
|
|
|
+ add("user_adverid_conver_7d");
|
|
|
+ add("user_adverid_view_30d");
|
|
|
+ add("user_adverid_click_30d");
|
|
|
+ add("user_adverid_conver_30d");
|
|
|
+ add("user_skuid_view_3d");
|
|
|
+ add("user_skuid_click_3d");
|
|
|
+ add("user_skuid_conver_3d");
|
|
|
+ add("user_skuid_view_7d");
|
|
|
+ add("user_skuid_click_7d");
|
|
|
+ add("user_skuid_conver_7d");
|
|
|
+ add("user_skuid_view_30d");
|
|
|
+ add("user_skuid_click_30d");
|
|
|
+ add("user_skuid_conver_30d");
|
|
|
+ add("user_layer_class");
|
|
|
+ }};
|
|
|
+ }
|
|
|
+
|
|
|
private Map<String, String> featureBucket(Map<String, String> featureMap) {
|
|
|
Map<String, String> newFeatureMap = new ConcurrentHashMap<>(featureMap.size());
|
|
|
for (Map.Entry<String, String> entry : featureMap.entrySet()) {
|
|
|
String name = entry.getKey();
|
|
|
+ if (this.sparseFeatureSet.contains(name)) {
|
|
|
+ if (entry.getValue() != null) {
|
|
|
+ newFeatureMap.put(name, entry.getValue());
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
double score = Double.parseDouble(entry.getValue());
|
|
|
// 注意:0值、不在分桶文件中的特征,会被过滤掉。
|
|
|
if (score > 1E-8) {
|
|
@@ -657,8 +887,6 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return newFeatureMap;
|
|
|
}
|
|
|
-
|
|
|
}
|