|
@@ -1,7 +1,6 @@
|
|
|
package com.tzld.piaoquan.recommend.server.implement;
|
|
|
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
import com.google.common.base.Stopwatch;
|
|
|
import com.google.common.reflect.TypeToken;
|
|
@@ -186,9 +185,18 @@ public class TopRecommendPipeline {
|
|
|
return rovRecallRankNewScore;
|
|
|
}
|
|
|
|
|
|
+ public Double calScoreWeightNoTimeDecay(List<Double> data) {
|
|
|
+ Double up = 0.0;
|
|
|
+ Double down = 0.0;
|
|
|
+ for (int i = 0; i < data.size(); ++i) {
|
|
|
+ up += 1.0 * data.get(i);
|
|
|
+ down += 1.0;
|
|
|
+ }
|
|
|
+ return down > 1E-8 ? up / down : 0.0;
|
|
|
+ }
|
|
|
+
|
|
|
private List<Video> rankItem2Video(List<RankItem> items) {
|
|
|
// 1 模型分
|
|
|
- List<String> rtFeaPart = new ArrayList<>();
|
|
|
List<String> rtFeaPartKey = new ArrayList<>(Arrays.asList("item_rt_fea_1day_partition", "item_rt_fea_1h_partition"));
|
|
|
List<String> rtFeaPartKeyResult = this.redisTemplate.opsForValue().multiGet(rtFeaPartKey);
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
@@ -207,7 +215,7 @@ public class TopRecommendPipeline {
|
|
|
datehours.add(cur);
|
|
|
cur = ExtractorUtils.subtractHours(cur, 1);
|
|
|
}
|
|
|
- for (RankItem item : items){
|
|
|
+ for (RankItem item : items) {
|
|
|
Map<String, String> itemBasicMap = item.getItemBasicFeature();
|
|
|
Map<String, Map<String, Double>> itemRealMap = item.getItemRealTimeFeature();
|
|
|
List<Double> views = getStaticData(itemRealMap, datehours, "view_pv_list_1h");
|
|
@@ -217,13 +225,13 @@ public class TopRecommendPipeline {
|
|
|
List<Double> allreturns = getStaticData(itemRealMap, datehours, "return_uv_list_1h");
|
|
|
|
|
|
List<Double> share2return = getRateData(preturns, shares, 1.0, 1000.0);
|
|
|
- Double share2returnScore = calScoreWeight(share2return);
|
|
|
+ Double share2returnScore = calScoreWeightNoTimeDecay(share2return);
|
|
|
List<Double> view2return = getRateData(preturns, views, 1.0, 1000.0);
|
|
|
- Double view2returnScore = calScoreWeight(view2return);
|
|
|
+ Double view2returnScore = calScoreWeightNoTimeDecay(view2return);
|
|
|
List<Double> view2play = getRateData(plays, views, 1.0, 1000.0);
|
|
|
- Double view2playScore = calScoreWeight(view2play);
|
|
|
+ Double view2playScore = calScoreWeightNoTimeDecay(view2play);
|
|
|
List<Double> play2share = getRateData(shares, plays, 1.0, 1000.0);
|
|
|
- Double play2shareScore = calScoreWeight(play2share);
|
|
|
+ Double play2shareScore = calScoreWeightNoTimeDecay(play2share);
|
|
|
item.scoresMap.put("share2returnScore", share2returnScore);
|
|
|
item.scoresMap.put("view2returnScore", view2returnScore);
|
|
|
item.scoresMap.put("view2playScore", view2playScore);
|
|
@@ -231,18 +239,18 @@ public class TopRecommendPipeline {
|
|
|
|
|
|
// 全部回流的rov和ros
|
|
|
List<Double> share2allreturn = getRateData(allreturns, shares, 1.0, 10.0);
|
|
|
- Double share2allreturnScore = calScoreWeight(share2allreturn);
|
|
|
+ Double share2allreturnScore = calScoreWeightNoTimeDecay(share2allreturn);
|
|
|
List<Double> view2allreturn = getRateData(allreturns, views, 0.0, 0.0);
|
|
|
- Double view2allreturnScore = calScoreWeight(view2allreturn);
|
|
|
+ Double view2allreturnScore = calScoreWeightNoTimeDecay(view2allreturn);
|
|
|
item.scoresMap.put("share2allreturnScore", share2allreturnScore);
|
|
|
item.scoresMap.put("view2allreturnScore", view2allreturnScore);
|
|
|
|
|
|
// 全部回流
|
|
|
- Double allreturnsScore = calScoreWeight(allreturns);
|
|
|
+ Double allreturnsScore = calScoreWeightNoTimeDecay(allreturns);
|
|
|
item.scoresMap.put("allreturnsScore", allreturnsScore);
|
|
|
|
|
|
// 平台回流
|
|
|
- Double preturnsScore = calScoreWeight(preturns);
|
|
|
+ Double preturnsScore = calScoreWeightNoTimeDecay(preturns);
|
|
|
item.scoresMap.put("preturnsScore", preturnsScore);
|
|
|
|
|
|
// rov的趋势
|