Procházet zdrojové kódy

83 sample 特征分割符

jch před 1 měsícem
rodič
revize
a28b829dea

+ 8 - 1
src/main/scala/com/aliyun/odps/spark/examples/myUtils/FeatureTransformV2.java

@@ -230,7 +230,14 @@ public class FeatureTransformV2 {
                             featMap.put(baseKey + "@uv", FeatureUtils.log1(uv, log1Scale));
                         }
                         if (ts > 0) {
-                            featMap.put(baseKey + "@ts", 1 - FeatureUtils.getTimeDiff(currentMs, ts * 1000));
+                            long historyMs = ts * 1000;
+                            featMap.put(baseKey + "@ts", 1 - FeatureUtils.getTimeDiff(currentMs, historyMs));
+
+                            // history week & hour
+                            Calendar calendar = Calendar.getInstance();
+                            calendar.setTimeInMillis(historyMs);
+                            featMap.put(String.format("%s_week@%d", baseKey, calendar.get(Calendar.DAY_OF_WEEK)), 1.0);
+                            featMap.put(String.format("%s_hour@%d", baseKey, calendar.get(Calendar.HOUR_OF_DAY) + 1), 1.0);
                         }
                         if (null != hVideoMap && hVideoMap.containsKey(vid)) {
                             Map<String, String> hVideo = hVideoMap.get(vid);