|
@@ -18,10 +18,10 @@ public class VideoAdThompsonModel extends Model{
|
|
|
private Map<String, AdActionFeature> featureCache = new HashMap<>();
|
|
|
private Map<Long, AdActionFeature> adActionFeatureMap = new HashMap<>();
|
|
|
private Map<Long, AdActionFeature> videoAdActionFeatureMap = new HashMap<>();
|
|
|
- private int alpha_click = 60;
|
|
|
- private int alpha_conv = 60;
|
|
|
- private int beta_click = 2000;
|
|
|
- private int beta_conversion = 2000;
|
|
|
+ private double alpha_click = 60;
|
|
|
+ private double alpha_conv = 60d;
|
|
|
+ private double beta_click = 1000d;
|
|
|
+ private double beta_conversion = 1000d;
|
|
|
|
|
|
@Override
|
|
|
public int getModelSize() {
|
|
@@ -33,6 +33,9 @@ public class VideoAdThompsonModel extends Model{
|
|
|
Map<String, AdActionFeature> initModel = new HashMap<>();
|
|
|
Map<Long, AdActionFeature> tempAdActionFeatureMap =new HashMap<>();
|
|
|
Map<Long, AdActionFeature> tempVideoActionFeatureMap =new HashMap<>();
|
|
|
+ double sumClick=0d;
|
|
|
+ double sumView=0d;
|
|
|
+ double sumConversion=0d;
|
|
|
try (BufferedReader reader = new BufferedReader(in)) {
|
|
|
String line = null;
|
|
|
int size = 0;
|
|
@@ -66,7 +69,12 @@ public class VideoAdThompsonModel extends Model{
|
|
|
conversion
|
|
|
);
|
|
|
size++;
|
|
|
+ sumClick+=click;
|
|
|
+ sumView+=view;
|
|
|
+ sumClick+=conversion;
|
|
|
}
|
|
|
+ double k=(sumConversion+sumView)/1000d;
|
|
|
+ this.alpha_conv=sumConversion/k;
|
|
|
this.featureCache = initModel;
|
|
|
this.adActionFeatureMap=tempAdActionFeatureMap;
|
|
|
this.videoAdActionFeatureMap=tempVideoActionFeatureMap;
|
|
@@ -109,8 +117,8 @@ public class VideoAdThompsonModel extends Model{
|
|
|
if(adActionFeature.getAdView()<1000){
|
|
|
adActionFeature=this.adActionFeatureMap.getOrDefault(item.getAdId(), new AdActionFeature());
|
|
|
}
|
|
|
- int alpha_ctr = (int) adActionFeature.getAdClick() + this.alpha_click;
|
|
|
- int beta_ctr = this.beta_click + (int) adActionFeature.getAdView() - (int) adActionFeature.getAdClick();
|
|
|
+ double alpha_ctr = (int) adActionFeature.getAdClick() + this.alpha_click;
|
|
|
+ double beta_ctr = this.beta_click + (int) adActionFeature.getAdView() - (int) adActionFeature.getAdClick();
|
|
|
return this.betaSampler(alpha_ctr, beta_ctr);
|
|
|
}
|
|
|
|
|
@@ -119,19 +127,28 @@ public class VideoAdThompsonModel extends Model{
|
|
|
if(adActionFeature.getAdView()<1000){
|
|
|
adActionFeature=this.adActionFeatureMap.getOrDefault(item.getAdId(), new AdActionFeature());
|
|
|
}
|
|
|
- int alpha_cvr = (int) adActionFeature.getAdConversion() + 10;
|
|
|
- int beta_cvr = 100 + (int) adActionFeature.getAdClick() - (int) adActionFeature.getAdConversion();
|
|
|
+ double alpha_cvr = (int) adActionFeature.getAdConversion() + 10d;
|
|
|
+ double beta_cvr = 100d + (int) adActionFeature.getAdClick() - (int) adActionFeature.getAdConversion();
|
|
|
return this.betaSampler(alpha_cvr, beta_cvr);
|
|
|
}
|
|
|
|
|
|
public double score(AdRankItem item) {
|
|
|
AdActionFeature adActionFeature = this.featureCache.getOrDefault(item.getVideoId()+"_"+item.getAdId(), new AdActionFeature());
|
|
|
- if(adActionFeature.getAdView()<1000){
|
|
|
+ double alpha_score=0d;
|
|
|
+ double beta_score=0d;
|
|
|
+ if(adActionFeature.getAdView()<200){
|
|
|
adActionFeature=this.adActionFeatureMap.getOrDefault(item.getAdId(), new AdActionFeature());
|
|
|
+ alpha_score = adActionFeature.getAdConversion() + this.alpha_conv;
|
|
|
+ beta_score = this.beta_conversion + adActionFeature.getAdView() - adActionFeature.getAdConversion();
|
|
|
+ }else {
|
|
|
+ AdActionFeature videoAdFeature=this.videoAdActionFeatureMap.getOrDefault(item.getVideoId(),new AdActionFeature());
|
|
|
+ double k=(videoAdFeature.getAdConversion()+videoAdFeature.getAdView())/1000d;
|
|
|
+ double alpha=(videoAdFeature.getAdConversion())/k;
|
|
|
+ alpha_score =adActionFeature.getAdConversion() + alpha;
|
|
|
+ beta_score = 1000d + adActionFeature.getAdView() - adActionFeature.getAdConversion();
|
|
|
}
|
|
|
- int alpha_cvr = (int) adActionFeature.getAdConversion() + 10;
|
|
|
- int beta_cvr = 100 + (int) adActionFeature.getAdClick() - (int) adActionFeature.getAdConversion();
|
|
|
- return this.betaSampler(alpha_cvr, beta_cvr);
|
|
|
+
|
|
|
+ return this.betaSampler(alpha_score, beta_score);
|
|
|
}
|
|
|
|
|
|
public double betaSampler(double alpha, double beta) {
|