Browse Source

ad feature to redis

sunmingze 1 year ago
parent
commit
fb948b203e

+ 9 - 9
ad-engine-commons/src/main/java/com/tzld/piaoquan/ad/engine/commons/base/AdActionFeature.java

@@ -12,13 +12,13 @@ public class AdActionFeature {
     private double cvr;
 
     private double ceilLog(Double key) {
-        return Math.ceil(Math.log(key));
+        return Math.ceil(Math.log(key + 1));
     }
 
     private double bucketRatioFeature(Double key) {
-        long bucket = Math.round(Math.log(key * 100));
-        if (bucket > 100)
-            bucket = 100;
+        long bucket = Math.round(Math.log((key + 1) * 1000));
+        if (bucket > 1000)
+            bucket = 1000;
         return (double) bucket;
     }
 
@@ -27,7 +27,7 @@ public class AdActionFeature {
         if (key == null) {
             this.adView = 0.0;
         } else {
-            String formateKey = key.toString().replace("\\N", "-1");
+            String formateKey = key.toString().replace("\\N", "0");
             this.adView = ceilLog(Double.valueOf(formateKey));
         }
     }
@@ -36,7 +36,7 @@ public class AdActionFeature {
         if (key == null) {
             this.adClick = 0.0;
         } else {
-            String formateKey = key.toString().replace("\\N", "-1");
+            String formateKey = key.toString().replace("\\N", "0");
             this.adClick = ceilLog(Double.valueOf(formateKey));
         }
     }
@@ -45,7 +45,7 @@ public class AdActionFeature {
         if (key == null) {
             this.adConversion = 0.0;
         } else {
-            String formateKey = key.toString().replace("\\N", "-1");
+            String formateKey = key.toString().replace("\\N", "0");
             this.adConversion = ceilLog(Double.valueOf(formateKey));
         }
     }
@@ -54,7 +54,7 @@ public class AdActionFeature {
         if (key == null) {
             this.ctr = 0.0;
         } else {
-            String formateKey = key.toString().replace("\\N", "-1");
+            String formateKey = key.toString().replace("\\N", "0");
             this.ctr = bucketRatioFeature(Double.valueOf(formateKey));
         }
     }
@@ -63,7 +63,7 @@ public class AdActionFeature {
         if (key == null) {
             this.cvr = 0.0;
         } else {
-            String formateKey = key.toString().replace("\\N", "-1");
+            String formateKey = key.toString().replace("\\N", "0");
             this.cvr = bucketRatioFeature(Double.valueOf(formateKey));
         }
     }