|
@@ -12,6 +12,7 @@ import com.tzld.piaoquan.recommend.feature.domain.ad.base.AdRankItem;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
+import org.apache.commons.lang.math.NumberUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -95,6 +96,18 @@ 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<>());
|
|
|
|
|
|
+ userFeatureMap.put("brand", request.getMachineInfo().getBrand().toUpperCase());
|
|
|
+ userFeatureMap.put("region", request.getRegion());
|
|
|
+ userFeatureMap.put("city", request.getCity());
|
|
|
+ userFeatureMap.put("vid", String.valueOf(request.getVideoId()));
|
|
|
+ userFeatureMap.put("merge_first_level_cate", d3Feature.get("merge_first_level_cate"));
|
|
|
+ userFeatureMap.put("merge_second_level_cate", 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));
|
|
|
+
|
|
|
Map<String, String> sceneFeatureMap = this.handleSceneFeature(ts);
|
|
|
long time1 = System.currentTimeMillis();
|
|
|
|
|
@@ -138,6 +151,10 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
this.handleC1UIFeature(midTimeDiffMap, actionStaticMap, cidFeatureMap, cidStr);
|
|
|
this.handleD1Feature(d1Feature, cidFeatureMap);
|
|
|
this.handleD2Feature(vidRankMaps, cidFeatureMap, cidStr);
|
|
|
+
|
|
|
+ cidFeatureMap.put("cid", dto.getCreativeId() != null ? String.valueOf(dto.getCreativeId()) : null);
|
|
|
+ cidFeatureMap.put("adid", dto.getAdId() != null ? String.valueOf(dto.getAdId()) : null);
|
|
|
+ cidFeatureMap.put("adverid", dto.getAdVerId());
|
|
|
return adRankItem;
|
|
|
} finally {
|
|
|
cdl1.countDown();
|
|
@@ -411,7 +428,18 @@ 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.isEmpty(midActionList)) {
|
|
|
+ List<String> cidList = new ArrayList<>();
|
|
|
+ List<String> converList = new ArrayList<>();
|
|
|
+ for (TupleMapEntry<Tuple5> tupleMapEntry : midActionList) {
|
|
|
+ String cid = tupleMapEntry.key;
|
|
|
+ String conver = tupleMapEntry.value.f3;
|
|
|
+ cidList.add(cid);
|
|
|
+ converList.add(conver);
|
|
|
+ }
|
|
|
+ featureMap.put("user_cid_click_list", String.join(",", cidList));
|
|
|
+ featureMap.put("user_cid_conver_list", String.join(",", converList));
|
|
|
+ }
|
|
|
return midActionList;
|
|
|
}
|
|
|
|
|
@@ -643,9 +671,18 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
}
|
|
|
|
|
|
private Map<String, String> featureBucket(Map<String, String> featureMap) {
|
|
|
+ Set<String> keys = new HashSet<String>() {{
|
|
|
+ add("cid");
|
|
|
+ add("adid");
|
|
|
+ add("adverid");
|
|
|
+ }};
|
|
|
Map<String, String> newFeatureMap = new ConcurrentHashMap<>(featureMap.size());
|
|
|
for (Map.Entry<String, String> entry : featureMap.entrySet()) {
|
|
|
String name = entry.getKey();
|
|
|
+ if (keys.contains(name)) {
|
|
|
+ newFeatureMap.put(name, entry.getKey());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
double score = Double.parseDouble(entry.getValue());
|
|
|
// 注意:0值、不在分桶文件中的特征,会被过滤掉。
|
|
|
if (score > 1E-8) {
|
|
@@ -659,7 +696,6 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return newFeatureMap;
|
|
|
}
|
|
|
|