|
@@ -1,6 +1,7 @@
|
|
|
package com.tzld.piaoquan.ad.engine.service.predict.model.threshold;
|
|
|
|
|
|
import com.tzld.piaoquan.ad.engine.commons.util.DateUtils;
|
|
|
+import com.tzld.piaoquan.ad.engine.commons.util.JSONUtils;
|
|
|
import com.tzld.piaoquan.ad.engine.service.predict.container.RandWContainer;
|
|
|
import com.tzld.piaoquan.ad.engine.service.predict.param.ThresholdPredictModelParam;
|
|
|
import org.slf4j.Logger;
|
|
@@ -22,25 +23,31 @@ public class RandomPredictModel extends ThresholdPredictModel {
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> predict(ThresholdPredictModelParam modelParam) {
|
|
|
- int hash=modelParam.getMid().hashCode();
|
|
|
- hash=hash<0?-hash:hash;
|
|
|
- double score=(hash+ RandWContainer.getRandW())%100/100d;
|
|
|
+ int hash = modelParam.getMid().hashCode();
|
|
|
+ hash = hash < 0 ? -hash : hash;
|
|
|
+ double score = (hash + RandWContainer.getRandW()) % 100 / 100d;
|
|
|
+
|
|
|
+ String keySuffix = modelParam.getUserExtraFuture("shareType").toString()
|
|
|
+ .replace("return", "")
|
|
|
+ .replace("mids", "");
|
|
|
|
|
|
- String keySuffix = modelParam.getUserExtraFuture("shareType").toString().replace("return", "").replace("mids", "");
|
|
|
Integer appType = modelParam.getAppType();
|
|
|
+ String thresholdParamKey = appType + "_" + keySuffix;
|
|
|
|
|
|
- double threshold = Double.parseDouble(modelParam.getExtraParam().getOrDefault(appType + "_" + keySuffix, -1).toString());
|
|
|
+ double threshold = Double.parseDouble(modelParam.getExtraParam().getOrDefault(thresholdParamKey, -1).toString());
|
|
|
if (threshold < 0d) {
|
|
|
- threshold = Double.parseDouble(modelParam.getExtraParam().getOrDefault("default_" + keySuffix, "-1").toString());
|
|
|
+ thresholdParamKey = "default_" + keySuffix;
|
|
|
+ threshold = Double.parseDouble(modelParam.getExtraParam().getOrDefault(thresholdParamKey, "-1").toString());
|
|
|
}
|
|
|
double correction = Double.parseDouble(modelParam.getExtraParam().getOrDefault("E620_" + appType + "_" + DateUtils.getCurrentHour(), 1).toString());
|
|
|
- threshold=threshold*correction;
|
|
|
+ threshold = threshold * correction;
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
- result.put("ad_predict", score<threshold?2:1);
|
|
|
+ result.put("ad_predict", score < threshold ? 2 : 1);
|
|
|
result.put("score", score);
|
|
|
result.put("threshold", threshold);
|
|
|
result.put("model", "random");
|
|
|
-
|
|
|
+ log.info("广告跳出选择 -- 599实验结果: {}, 参数: {}, {}, {}",
|
|
|
+ JSONUtils.toJson(result), appType, modelParam.getMid(), thresholdParamKey);
|
|
|
return result;
|
|
|
}
|
|
|
|