|
@@ -43,52 +43,6 @@ public class VideoAdThompsonScorerV2 {
|
|
Random random = new Random();
|
|
Random random = new Random();
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
|
|
|
|
- // public List<AdRankItem> thompsonScorerByExp663(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
|
|
|
|
- // List<AdRankItem> result = new LinkedList<>();
|
|
|
|
- // String jsonStr;
|
|
|
|
- // CreativeStatistic statistic = null;
|
|
|
|
- // List<String> redisKey = new LinkedList<>();
|
|
|
|
- // adIdList.forEach(creativeDTO -> {
|
|
|
|
- // redisKey.add(redisCreativeStatisticsPrefix + creativeDTO.getCreativeId());
|
|
|
|
- // });
|
|
|
|
- // List<String> values = redisHelper.getValues(redisKey);
|
|
|
|
- // double score = 0d;
|
|
|
|
- // int i = 0;
|
|
|
|
- // for (AdPlatformCreativeDTO dto : adIdList) {
|
|
|
|
- // AdRankItem item = new AdRankItem();
|
|
|
|
- // item.setVideoId(param.getVideoId());
|
|
|
|
- // item.setCpa(dto.getCpa());
|
|
|
|
- // item.setAdId(dto.getCreativeId());
|
|
|
|
- // try {
|
|
|
|
- // jsonStr = values.get(i);
|
|
|
|
- // if (jsonStr == null) {
|
|
|
|
- // score = exp663Param.getOrDefault("randomMin", 0.000001)
|
|
|
|
- // + (random.nextDouble() *
|
|
|
|
- // (exp663Param.getOrDefault("randomMax", 0.00001) - exp663Param.getOrDefault("randomMin", 0.000001)));
|
|
|
|
- // } else {
|
|
|
|
- // statistic = gson.fromJson(jsonStr, CreativeStatistic.class);
|
|
|
|
- // score = (exp663Param.getOrDefault("alpha", 1d) + Long.parseLong(statistic.getOrder()))
|
|
|
|
- // / (exp663Param.getOrDefault("beta", 10000d) + Long.parseLong(statistic.getExp()));
|
|
|
|
- // }
|
|
|
|
- // double s1 = score;
|
|
|
|
- // score = score * dto.getCpa() * dto.getBid1() * dto.getBid2();
|
|
|
|
- //
|
|
|
|
- // Map<String, Object> ext = this.extMap(statistic, "663", dto.getCpa(), null,
|
|
|
|
- // exp663Param.getOrDefault("alpha", 1d), exp663Param.getOrDefault("beta", 10000d), null);
|
|
|
|
- // ext.put("s1", s1);
|
|
|
|
- // item.setFeature(ext);
|
|
|
|
- // item.setScore(score);
|
|
|
|
- // item.setScore_type(663);
|
|
|
|
- // } catch (Exception e) {
|
|
|
|
- // log.error("svc=thompsonScorerByExp663 {}", gson.toJson(e.getStackTrace()));
|
|
|
|
- // }
|
|
|
|
- // result.add(item);
|
|
|
|
- // i++;
|
|
|
|
- // }
|
|
|
|
- // Collections.sort(result);
|
|
|
|
- // return result;
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
public List<AdRankItem> thompsonScorerByExp663(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
|
|
public List<AdRankItem> thompsonScorerByExp663(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
|
|
List<AdRankItem> result = new LinkedList<>();
|
|
List<AdRankItem> result = new LinkedList<>();
|
|
Map<Long, CreativeStatistic> creativeStatisticsMap = this.batchFindCreativeRedisCache(redisCreativeStatisticsPrefix, adIdList);
|
|
Map<Long, CreativeStatistic> creativeStatisticsMap = this.batchFindCreativeRedisCache(redisCreativeStatisticsPrefix, adIdList);
|
|
@@ -244,75 +198,6 @@ public class VideoAdThompsonScorerV2 {
|
|
Collections.sort(result);
|
|
Collections.sort(result);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
- // public List<AdRankItem> thompsonScorerByExp666(ScoreParam param,List<AdPlatformCreativeDTO> adIdList){
|
|
|
|
- // List<AdRankItem> result=new LinkedList<>();
|
|
|
|
- // String jsonStr;
|
|
|
|
- // CreativeStatistic statistic = null;
|
|
|
|
- //
|
|
|
|
- // List<String> redisKey=new LinkedList<>();
|
|
|
|
- // adIdList.forEach(creativeDTO -> {
|
|
|
|
- // redisKey.add(redisCreativeStatisticsPrefix+creativeDTO.getCreativeId());
|
|
|
|
- // });
|
|
|
|
- // List<String> values=redisHelper.getValues(redisKey);
|
|
|
|
- // List<String> combineKeys=new LinkedList<>();
|
|
|
|
- // adIdList.forEach(creativeDTO -> {
|
|
|
|
- // combineKeys.add(redisVideoCreativeStatisticsPrefix+param.getVideoId()+"_"+creativeDTO.getCreativeId());
|
|
|
|
- // });
|
|
|
|
- // List<String> combineValues=redisHelper.getValues(combineKeys);
|
|
|
|
- // int i=0;
|
|
|
|
- // double score=0d;
|
|
|
|
- // for(AdPlatformCreativeDTO dto:adIdList){
|
|
|
|
- // String statisticType = "vid+cid";
|
|
|
|
- // AdRankItem item=new AdRankItem();
|
|
|
|
- // item.setVideoId(param.getVideoId());
|
|
|
|
- // item.setCpa(dto.getCpa());
|
|
|
|
- // item.setAdId(dto.getCreativeId());
|
|
|
|
- // try {
|
|
|
|
- // jsonStr=combineValues.get(i);
|
|
|
|
- // if(jsonStr==null){
|
|
|
|
- // jsonStr=values.get(i);
|
|
|
|
- // if(jsonStr==null){
|
|
|
|
- // statisticType = "";
|
|
|
|
- // score = betaSampler(exp666Param.getOrDefault("alpha",1d),exp666Param.getOrDefault("beta",100000d));
|
|
|
|
- // }else {
|
|
|
|
- // statisticType = "cid";
|
|
|
|
- // statistic =gson.fromJson(jsonStr,CreativeStatistic.class);
|
|
|
|
- // score = betaSampler(exp666Param.getOrDefault("alpha",1d)+Long.parseLong(statistic.getOrder()) ,
|
|
|
|
- // (exp666Param.getOrDefault("beta",100000d)+Long.parseLong(statistic.getExp()))/(1+exp666Param.getOrDefault("beta_k",9d))) ;
|
|
|
|
- // }
|
|
|
|
- // }else {
|
|
|
|
- // statistic =gson.fromJson(jsonStr,CreativeStatistic.class);
|
|
|
|
- // if(Double.parseDouble(statistic.getExp())>exp666Param.getOrDefault("viewThreshold",5000d)){
|
|
|
|
- // score = betaSampler(exp666Param.getOrDefault("alpha",1d)+Long.parseLong(statistic.getOrder()) ,
|
|
|
|
- // (exp666Param.getOrDefault("beta",100000d)+Long.parseLong(statistic.getExp()))/(1+exp666Param.getOrDefault("beta_k",9d))) ;
|
|
|
|
- // } else if( values.get(i)!=null) {
|
|
|
|
- // statistic =gson.fromJson(values.get(i),CreativeStatistic.class);
|
|
|
|
- // score = betaSampler(exp666Param.getOrDefault("alpha",1d)+Long.parseLong(statistic.getOrder()) ,
|
|
|
|
- // (exp666Param.getOrDefault("beta",100000d)+Long.parseLong(statistic.getExp()))/(1+exp666Param.getOrDefault("beta_k",9d))) ;
|
|
|
|
- // }else {
|
|
|
|
- // score = betaSampler(exp666Param.getOrDefault("alpha",1d),exp666Param.getOrDefault("beta",100000d));
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // double s1 = score;
|
|
|
|
- // score=score*dto.getCpa()*dto.getBid1()*dto.getBid2();
|
|
|
|
- // item.setScore(score);
|
|
|
|
- // item.setScore_type(666);
|
|
|
|
- //
|
|
|
|
- // Map<String, Object> ext = this.extMap(statistic, "666", dto.getCpa(), exp666Param.getOrDefault("viewThreshold",5000d), exp663Param.getOrDefault("alpha", 1d),
|
|
|
|
- // exp663Param.getOrDefault("beta", 10000d), exp666Param.getOrDefault("beta_k",9d));
|
|
|
|
- // ext.put("s1", s1);
|
|
|
|
- // ext.put("group_field", statisticType);
|
|
|
|
- // item.setFeature(ext);
|
|
|
|
- //
|
|
|
|
- // }catch (Exception e){
|
|
|
|
- // log.error("svc=thompsonScorerByExp666 {}",gson.toJson(e.getStackTrace()));
|
|
|
|
- // }
|
|
|
|
- // result.add(item);
|
|
|
|
- // i++;
|
|
|
|
- // }
|
|
|
|
- // Collections.sort(result);
|
|
|
|
- // return result;
|
|
|
|
- // }
|
|
|
|
|
|
|
|
public List<AdRankItem> thompsonScorerByExp666(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
|
|
public List<AdRankItem> thompsonScorerByExp666(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
|
|
List<AdRankItem> result = new LinkedList<>();
|
|
List<AdRankItem> result = new LinkedList<>();
|