|
@@ -10,20 +10,12 @@ public class AdItemBytesFeature {
|
|
|
|
|
|
private final byte[] adId;
|
|
private final byte[] adId;
|
|
|
|
|
|
- //private final byte[] adCode;
|
|
|
|
-
|
|
|
|
private final byte[] advertiserId;
|
|
private final byte[] advertiserId;
|
|
|
|
|
|
- //private final byte[] advertiserCode;
|
|
|
|
-
|
|
|
|
private final byte[] campaignId;
|
|
private final byte[] campaignId;
|
|
|
|
|
|
- //private final byte[] campaignCode;
|
|
|
|
-
|
|
|
|
private final byte[] creative;
|
|
private final byte[] creative;
|
|
|
|
|
|
- //private final byte[] creativeCode;
|
|
|
|
-
|
|
|
|
// adid 维度,也就是planid
|
|
// adid 维度,也就是planid
|
|
private Map<String, byte[]> day1_cnt_features;
|
|
private Map<String, byte[]> day1_cnt_features;
|
|
// 3天内统计量
|
|
// 3天内统计量
|
|
@@ -54,127 +46,92 @@ public class AdItemBytesFeature {
|
|
private Map<String, byte[]> advertiser_month3_cnt_features;
|
|
private Map<String, byte[]> advertiser_month3_cnt_features;
|
|
|
|
|
|
|
|
|
|
|
|
+ private static void addAdActionFeature(Map<String, byte[]> dayCntMap, AdActionFeature adActionFeature ){
|
|
|
|
+
|
|
|
|
+ dayCntMap.put("view", String.valueOf(ceilLog(adActionFeature.getAdView())).getBytes());
|
|
|
|
+ dayCntMap.put("click", String.valueOf(ceilLog(adActionFeature.getAdClick())).getBytes());
|
|
|
|
+ dayCntMap.put("conversion", String.valueOf(ceilLog(adActionFeature.getAdConversion())).getBytes());
|
|
|
|
+ dayCntMap.put("ctr", String.valueOf(bucketRatioFeature(adActionFeature.getCtr())).getBytes());
|
|
|
|
+ dayCntMap.put("cvr", String.valueOf(bucketRatioFeature(adActionFeature.getCvr())).getBytes());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static double ceilLog(Double key) {
|
|
|
|
+ return Math.ceil(Math.log(key + 1));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static double bucketRatioFeature(Double key) {
|
|
|
|
+ long bucket = Math.round(Math.log((key + 1) * 50));
|
|
|
|
+ if (bucket > 50)
|
|
|
|
+ bucket = 50;
|
|
|
|
+ return (double) bucket;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
public AdItemBytesFeature(AdItemFeature feature) {
|
|
public AdItemBytesFeature(AdItemFeature feature) {
|
|
|
|
|
|
adId = feature.getAdId().getBytes();
|
|
adId = feature.getAdId().getBytes();
|
|
- // adCode = feature.getAdCode().getBytes();
|
|
|
|
advertiserId = feature.getAdvertiserId().getBytes();
|
|
advertiserId = feature.getAdvertiserId().getBytes();
|
|
- //advertiserCode = feature.getAdvertiserCode().getBytes();
|
|
|
|
campaignId = feature.getCampaignId().getBytes();
|
|
campaignId = feature.getCampaignId().getBytes();
|
|
- //campaignCode = feature.getCampaignCode().getBytes();
|
|
|
|
creative = feature.getCreativeId().getBytes();
|
|
creative = feature.getCreativeId().getBytes();
|
|
- // creativeCode = feature.getCreativeCode().getBytes();
|
|
|
|
|
|
|
|
|
|
|
|
// adid 维度 planid
|
|
// adid 维度 planid
|
|
// 1 day statistic
|
|
// 1 day statistic
|
|
day1_cnt_features = new HashMap<String, byte[]>();
|
|
day1_cnt_features = new HashMap<String, byte[]>();
|
|
- day1_cnt_features.put("view", String.valueOf(feature.getDay1_cnt_features().getAdView()).getBytes());
|
|
|
|
- day1_cnt_features.put("click", String.valueOf(feature.getDay1_cnt_features().getAdClick()).getBytes());
|
|
|
|
- day1_cnt_features.put("conversion", String.valueOf(feature.getDay1_cnt_features().getAdConversion()).getBytes());
|
|
|
|
- day1_cnt_features.put("ctr", String.valueOf(feature.getDay1_cnt_features().getCtr()).getBytes());
|
|
|
|
- day1_cnt_features.put("cvr", String.valueOf(feature.getDay1_cnt_features().getCvr()).getBytes());
|
|
|
|
|
|
+ addAdActionFeature(day1_cnt_features, feature.getDay1_cnt_features());
|
|
|
|
|
|
// 3 day statistic
|
|
// 3 day statistic
|
|
day3_cnt_features = new HashMap<String, byte[]>();
|
|
day3_cnt_features = new HashMap<String, byte[]>();
|
|
- day3_cnt_features.put("view", String.valueOf(feature.getDay3_cnt_features().getAdView()).getBytes());
|
|
|
|
- day3_cnt_features.put("click", String.valueOf(feature.getDay3_cnt_features().getAdClick()).getBytes());
|
|
|
|
- day3_cnt_features.put("conversion", String.valueOf(feature.getDay3_cnt_features().getAdConversion()).getBytes());
|
|
|
|
- day3_cnt_features.put("ctr", String.valueOf(feature.getDay3_cnt_features().getCtr()).getBytes());
|
|
|
|
- day3_cnt_features.put("cvr", String.valueOf(feature.getDay3_cnt_features().getCvr()).getBytes());
|
|
|
|
|
|
+ addAdActionFeature(day3_cnt_features, feature.getDay3_cnt_features());
|
|
|
|
|
|
// 7 day statistic
|
|
// 7 day statistic
|
|
day7_cnt_features = new HashMap<String, byte[]>();
|
|
day7_cnt_features = new HashMap<String, byte[]>();
|
|
- day7_cnt_features.put("view", String.valueOf(feature.getDay7_cnt_features().getAdView()).getBytes());
|
|
|
|
- day7_cnt_features.put("click", String.valueOf(feature.getDay7_cnt_features().getAdClick()).getBytes());
|
|
|
|
- day7_cnt_features.put("conversion", String.valueOf(feature.getDay7_cnt_features().getAdConversion()).getBytes());
|
|
|
|
- day7_cnt_features.put("ctr", String.valueOf(feature.getDay7_cnt_features().getCtr()).getBytes());
|
|
|
|
- day7_cnt_features.put("cvr", String.valueOf(feature.getDay7_cnt_features().getCvr()).getBytes());
|
|
|
|
|
|
+ addAdActionFeature(day7_cnt_features, feature.getDay7_cnt_features());
|
|
|
|
|
|
// 3 month statisic
|
|
// 3 month statisic
|
|
month3_cnt_features = new HashMap<String, byte[]>();
|
|
month3_cnt_features = new HashMap<String, byte[]>();
|
|
- month3_cnt_features.put("view", String.valueOf(feature.getMonth3_cnt_features().getAdView()).getBytes());
|
|
|
|
- month3_cnt_features.put("click", String.valueOf(feature.getMonth3_cnt_features().getAdClick()).getBytes());
|
|
|
|
- month3_cnt_features.put("conversion", String.valueOf(feature.getMonth3_cnt_features().getAdConversion()).getBytes());
|
|
|
|
- month3_cnt_features.put("ctr", String.valueOf(feature.getMonth3_cnt_features().getCtr()).getBytes());
|
|
|
|
- month3_cnt_features.put("cvr", String.valueOf(feature.getMonth3_cnt_features().getCvr()).getBytes());
|
|
|
|
|
|
+ addAdActionFeature(month3_cnt_features, feature.getMonth3_cnt_features());
|
|
|
|
|
|
|
|
|
|
// creative 维度 creativeid
|
|
// creative 维度 creativeid
|
|
// 1 day statistic
|
|
// 1 day statistic
|
|
creative_day1_cnt_features = new HashMap<String, byte[]>();
|
|
creative_day1_cnt_features = new HashMap<String, byte[]>();
|
|
- creative_day1_cnt_features.put("view", String.valueOf(feature.getCreative_1day_cnt_features().getAdView()).getBytes());
|
|
|
|
- creative_day1_cnt_features.put("click", String.valueOf(feature.getCreative_1day_cnt_features().getAdClick()).getBytes());
|
|
|
|
- creative_day1_cnt_features.put("conversion", String.valueOf(feature.getCreative_1day_cnt_features().getAdConversion()).getBytes());
|
|
|
|
- creative_day1_cnt_features.put("ctr", String.valueOf(feature.getCreative_1day_cnt_features().getCtr()).getBytes());
|
|
|
|
- creative_day1_cnt_features.put("cvr", String.valueOf(feature.getCreative_1day_cnt_features().getCvr()).getBytes());
|
|
|
|
|
|
+ addAdActionFeature(creative_day1_cnt_features, feature.getCreative_1day_cnt_features());
|
|
|
|
|
|
// 3 day statistic
|
|
// 3 day statistic
|
|
creative_day3_cnt_features = new HashMap<String, byte[]>();
|
|
creative_day3_cnt_features = new HashMap<String, byte[]>();
|
|
- creative_day3_cnt_features.put("view", String.valueOf(feature.getDay3_cnt_features().getAdView()).getBytes());
|
|
|
|
- creative_day3_cnt_features.put("click", String.valueOf(feature.getDay3_cnt_features().getAdClick()).getBytes());
|
|
|
|
- creative_day3_cnt_features.put("conversion", String.valueOf(feature.getDay3_cnt_features().getAdConversion()).getBytes());
|
|
|
|
- creative_day3_cnt_features.put("ctr", String.valueOf(feature.getDay3_cnt_features().getCtr()).getBytes());
|
|
|
|
- creative_day3_cnt_features.put("cvr", String.valueOf(feature.getDay3_cnt_features().getCvr()).getBytes());
|
|
|
|
|
|
+ addAdActionFeature(creative_day3_cnt_features, feature.getCreative_3day_cnt_features());
|
|
|
|
+
|
|
|
|
|
|
// 7 day statistic
|
|
// 7 day statistic
|
|
creative_day7_cnt_features = new HashMap<String, byte[]>();
|
|
creative_day7_cnt_features = new HashMap<String, byte[]>();
|
|
- creative_day7_cnt_features.put("view", String.valueOf(feature.getDay7_cnt_features().getAdView()).getBytes());
|
|
|
|
- creative_day7_cnt_features.put("click", String.valueOf(feature.getDay7_cnt_features().getAdClick()).getBytes());
|
|
|
|
- creative_day7_cnt_features.put("conversion", String.valueOf(feature.getDay7_cnt_features().getAdConversion()).getBytes());
|
|
|
|
- creative_day7_cnt_features.put("ctr", String.valueOf(feature.getDay7_cnt_features().getCtr()).getBytes());
|
|
|
|
- creative_day7_cnt_features.put("cvr", String.valueOf(feature.getDay7_cnt_features().getCvr()).getBytes());
|
|
|
|
|
|
+ addAdActionFeature(creative_day7_cnt_features, feature.getCreative_7day_cnt_features());
|
|
|
|
|
|
|
|
|
|
// 3 month statisic
|
|
// 3 month statisic
|
|
creative_month3_cnt_features = new HashMap<String, byte[]>();
|
|
creative_month3_cnt_features = new HashMap<String, byte[]>();
|
|
- creative_month3_cnt_features.put("view", String.valueOf(feature.getMonth3_cnt_features().getAdView()).getBytes());
|
|
|
|
- creative_month3_cnt_features.put("click", String.valueOf(feature.getMonth3_cnt_features().getAdClick()).getBytes());
|
|
|
|
- creative_month3_cnt_features.put("conversion", String.valueOf(feature.getMonth3_cnt_features().getAdConversion()).getBytes());
|
|
|
|
- creative_month3_cnt_features.put("ctr", String.valueOf(feature.getMonth3_cnt_features().getCtr()).getBytes());
|
|
|
|
- creative_month3_cnt_features.put("cvr", String.valueOf(feature.getMonth3_cnt_features().getCvr()).getBytes());
|
|
|
|
-
|
|
|
|
|
|
+ addAdActionFeature(creative_month3_cnt_features, feature.getCreative_3month_cnt_features());
|
|
|
|
|
|
|
|
|
|
// advertiser 维度 planid
|
|
// advertiser 维度 planid
|
|
// 1 day statistic
|
|
// 1 day statistic
|
|
advertiser_day1_cnt_features = new HashMap<String, byte[]>();
|
|
advertiser_day1_cnt_features = new HashMap<String, byte[]>();
|
|
- advertiser_day1_cnt_features.put("view", String.valueOf(feature.getAdvertiser_1day_cnt_features().getAdView()).getBytes());
|
|
|
|
- advertiser_day1_cnt_features.put("click", String.valueOf(feature.getAdvertiser_1day_cnt_features().getAdClick()).getBytes());
|
|
|
|
- advertiser_day1_cnt_features.put("conversion", String.valueOf(feature.getAdvertiser_1day_cnt_features().getAdConversion()).getBytes());
|
|
|
|
- advertiser_day1_cnt_features.put("ctr", String.valueOf(feature.getAdvertiser_1day_cnt_features().getCtr()).getBytes());
|
|
|
|
- advertiser_day1_cnt_features.put("cvr", String.valueOf(feature.getAdvertiser_1day_cnt_features().getCvr()).getBytes());
|
|
|
|
|
|
+ addAdActionFeature(advertiser_day1_cnt_features, feature.getAdvertiser_1day_cnt_features());
|
|
|
|
|
|
|
|
|
|
// 3 day statistic
|
|
// 3 day statistic
|
|
advertiser_day3_cnt_features = new HashMap<String, byte[]>();
|
|
advertiser_day3_cnt_features = new HashMap<String, byte[]>();
|
|
- advertiser_day3_cnt_features.put("view", String.valueOf(feature.getAdvertiser_3day_cnt_features().getAdView()).getBytes());
|
|
|
|
- advertiser_day3_cnt_features.put("click", String.valueOf(feature.getAdvertiser_3day_cnt_features().getAdClick()).getBytes());
|
|
|
|
- advertiser_day3_cnt_features.put("conversion", String.valueOf(feature.getAdvertiser_3day_cnt_features().getAdConversion()).getBytes());
|
|
|
|
- advertiser_day3_cnt_features.put("ctr", String.valueOf(feature.getAdvertiser_3day_cnt_features().getCtr()).getBytes());
|
|
|
|
- advertiser_day3_cnt_features.put("cvr", String.valueOf(feature.getAdvertiser_3day_cnt_features().getCvr()).getBytes());
|
|
|
|
|
|
+ addAdActionFeature(advertiser_day3_cnt_features, feature.getAdvertiser_3day_cnt_features());
|
|
|
|
|
|
|
|
|
|
// 7 day statistic
|
|
// 7 day statistic
|
|
advertiser_day7_cnt_features = new HashMap<String, byte[]>();
|
|
advertiser_day7_cnt_features = new HashMap<String, byte[]>();
|
|
- advertiser_day7_cnt_features.put("view", String.valueOf(feature.getAdvertiser_7day_cnt_features().getAdView()).getBytes());
|
|
|
|
- advertiser_day7_cnt_features.put("click", String.valueOf(feature.getAdvertiser_7day_cnt_features().getAdClick()).getBytes());
|
|
|
|
- advertiser_day7_cnt_features.put("conversion", String.valueOf(feature.getAdvertiser_7day_cnt_features().getAdConversion()).getBytes());
|
|
|
|
- advertiser_day7_cnt_features.put("ctr", String.valueOf(feature.getAdvertiser_7day_cnt_features().getCtr()).getBytes());
|
|
|
|
- advertiser_day7_cnt_features.put("cvr", String.valueOf(feature.getAdvertiser_7day_cnt_features().getCvr()).getBytes());
|
|
|
|
-
|
|
|
|
|
|
+ addAdActionFeature(advertiser_day7_cnt_features, feature.getAdvertiser_7day_cnt_features());
|
|
|
|
|
|
// 3 month statisic
|
|
// 3 month statisic
|
|
advertiser_month3_cnt_features = new HashMap<String, byte[]>();
|
|
advertiser_month3_cnt_features = new HashMap<String, byte[]>();
|
|
- advertiser_month3_cnt_features.put("view", String.valueOf(feature.getAdvertiser_3month_cnt_features().getAdView()).getBytes());
|
|
|
|
- advertiser_month3_cnt_features.put("click", String.valueOf(feature.getAdvertiser_3month_cnt_features().getAdClick()).getBytes());
|
|
|
|
- advertiser_month3_cnt_features.put("conversion", String.valueOf(feature.getAdvertiser_3month_cnt_features().getAdConversion()).getBytes());
|
|
|
|
- advertiser_month3_cnt_features.put("ctr", String.valueOf(feature.getAdvertiser_3month_cnt_features().getCtr()).getBytes());
|
|
|
|
- advertiser_month3_cnt_features.put("cvr", String.valueOf(feature.getAdvertiser_3month_cnt_features().getCvr()).getBytes());
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ addAdActionFeature(advertiser_month3_cnt_features, feature.getAdvertiser_3month_cnt_features());
|
|
|
|
|
|
|
|
|
|
|
|
|