|
@@ -362,11 +362,9 @@ public class RankStrategyBy897 extends RankStrategyBasic {
|
|
|
double maxValidCopc = NumberUtils.toDouble(paramsMap.getOrDefault("maxValidCopc", "10"));
|
|
double maxValidCopc = NumberUtils.toDouble(paramsMap.getOrDefault("maxValidCopc", "10"));
|
|
|
double minCopc = NumberUtils.toDouble(paramsMap.getOrDefault("minCopc", "0.2"));
|
|
double minCopc = NumberUtils.toDouble(paramsMap.getOrDefault("minCopc", "0.2"));
|
|
|
double maxCopc = NumberUtils.toDouble(paramsMap.getOrDefault("maxCopc", "2.5"));
|
|
double maxCopc = NumberUtils.toDouble(paramsMap.getOrDefault("maxCopc", "2.5"));
|
|
|
- boolean cidCtcvrCorrected = calibrationCidCtcvr(result, calibModelName, reqFeature,
|
|
|
|
|
|
|
+ List<AdRankItem> layerTargetCopcFallbackItems = calibrationCidCtcvr(result, calibModelName, reqFeature,
|
|
|
minValidCopc, maxValidCopc, minCopc, maxCopc);
|
|
minValidCopc, maxValidCopc, minCopc, maxCopc);
|
|
|
- if (!cidCtcvrCorrected) {
|
|
|
|
|
- calculateLayerTargetCopc(result, calibModelName, reqFeature);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ calculateLayerTargetCopc(layerTargetCopcFallbackItems, calibModelName, reqFeature);
|
|
|
if (CollectionUtils.isEmpty(result)) {
|
|
if (CollectionUtils.isEmpty(result)) {
|
|
|
log.error("calculateCtcvrScore result is empty");
|
|
log.error("calculateCtcvrScore result is empty");
|
|
|
}
|
|
}
|
|
@@ -1118,30 +1116,47 @@ public class RankStrategyBy897 extends RankStrategyBasic {
|
|
|
return Math.min(Math.max(lowerWeight, weight), upperWeight);
|
|
return Math.min(Math.max(lowerWeight, weight), upperWeight);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private boolean calibrationCidCtcvr(List<AdRankItem> items, String modelName, Map<String, String> reqFeature,
|
|
|
|
|
- double minValid, double maxValid,
|
|
|
|
|
- double minVal, double maxVal) {
|
|
|
|
|
- boolean corrected = false;
|
|
|
|
|
- try {
|
|
|
|
|
- String layer = reqFeature.get("layer_l6");
|
|
|
|
|
- for (AdRankItem item : items) {
|
|
|
|
|
|
|
+ private List<AdRankItem> calibrationCidCtcvr(List<AdRankItem> items, String modelName,
|
|
|
|
|
+ Map<String, String> reqFeature,
|
|
|
|
|
+ double minValid, double maxValid,
|
|
|
|
|
+ double minVal, double maxVal) {
|
|
|
|
|
+ if (CollectionUtils.isEmpty(items)) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<AdRankItem> fallbackItems = new ArrayList<>();
|
|
|
|
|
+ String layer = MapUtils.isEmpty(reqFeature) ? null : reqFeature.get("layer_l6");
|
|
|
|
|
+ if (StringUtils.isBlank(modelName) || StringUtils.isBlank(layer)) {
|
|
|
|
|
+ fallbackItems.addAll(items);
|
|
|
|
|
+ return fallbackItems;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (AdRankItem item : items) {
|
|
|
|
|
+ if (item == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
String cid = String.valueOf(item.getAdId());
|
|
String cid = String.valueOf(item.getAdId());
|
|
|
Double diff = CreativeUserLayerDataHelperV2L6.getCopc(modelName, cid, layer);
|
|
Double diff = CreativeUserLayerDataHelperV2L6.getCopc(modelName, cid, layer);
|
|
|
- if (null != diff) {
|
|
|
|
|
- double newDiff = Math.min(Math.max(minVal, diff), maxVal);
|
|
|
|
|
- if (newDiff < minValid || newDiff > maxValid) {
|
|
|
|
|
- double ctcvr = item.getLrScore() * newDiff;
|
|
|
|
|
- item.getScoreMap().put("cidCtcvrScore", ctcvr);
|
|
|
|
|
- item.getScoreMap().put("ctcvrScore", ctcvr);
|
|
|
|
|
- item.setLrScore(ctcvr);
|
|
|
|
|
- corrected = true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (diff == null) {
|
|
|
|
|
+ fallbackItems.add(item);
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ double newDiff = Math.min(Math.max(minVal, diff), maxVal);
|
|
|
|
|
+ if (newDiff < minValid || newDiff > maxValid) {
|
|
|
|
|
+ double ctcvr = item.getLrScore() * newDiff;
|
|
|
|
|
+ item.getScoreMap().put("cidCtcvrScore", ctcvr);
|
|
|
|
|
+ item.getScoreMap().put("ctcvrScore", ctcvr);
|
|
|
|
|
+ item.setLrScore(ctcvr);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("calibrationCidCtcvr error, adId={}", item.getAdId(), e);
|
|
|
|
|
+ fallbackItems.add(item);
|
|
|
}
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("calibCidScore error", e);
|
|
|
|
|
}
|
|
}
|
|
|
- return corrected;
|
|
|
|
|
|
|
+ return fallbackItems;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void calculateLayerTargetCopc(List<AdRankItem> items, String modelName, Map<String, String> reqFeature) {
|
|
private void calculateLayerTargetCopc(List<AdRankItem> items, String modelName, Map<String, String> reqFeature) {
|