|
@@ -0,0 +1,45 @@
|
|
|
+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.service.predict.container.RandWContainer;
|
|
|
+import com.tzld.piaoquan.ad.engine.service.predict.param.ThresholdPredictModelParam;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class RandomPredict667Model extends ThresholdPredictModel {
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(RandomPredict667Model.class);
|
|
|
+
|
|
|
+ @Override
|
|
|
+ String initName() {
|
|
|
+ return "random667";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @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;
|
|
|
+ double threshold=Double.parseDouble(
|
|
|
+ modelParam.getExtraParam().getOrDefault(modelParam.getAppType()+"_"+modelParam.getUserExtraFuture("shareType").toString().replace("return","").replace("mids",""),-1
|
|
|
+ ).toString());
|
|
|
+ if(threshold<0d){
|
|
|
+ threshold=Double.parseDouble(
|
|
|
+ modelParam.getExtraParam().getOrDefault("default_threshold","0.5")
|
|
|
+ .toString());
|
|
|
+ }
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("ad_predict", score<threshold?2:1);
|
|
|
+ result.put("score", score);
|
|
|
+ result.put("threshold", threshold);
|
|
|
+ result.put("model", initName());
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|