| 
														
															@@ -28,6 +28,10 @@ public class ThompsonSamplingModel extends Model { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // key = adid, value = <exp, click, conversation> 
														 | 
														
														 | 
														
															     // key = adid, value = <exp, click, conversation> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     private Map<Long, AdActionFeature> thompsonSamplingModel; 
														 | 
														
														 | 
														
															     private Map<Long, AdActionFeature> thompsonSamplingModel; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private static final int alpha = 6; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private static final int beta_click = 100; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private static final int beta_conversion = 1000; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public ThompsonSamplingModel() { 
														 | 
														
														 | 
														
															     public ThompsonSamplingModel() { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         //配置不同环境的hdfs conf 
														 | 
														
														 | 
														
															         //配置不同环境的hdfs conf 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         this.thompsonSamplingModel = new HashMap<>(); 
														 | 
														
														 | 
														
															         this.thompsonSamplingModel = new HashMap<>(); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -80,10 +84,16 @@ public class ThompsonSamplingModel extends Model { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public double score(AdRankItem adRankItem, String ctrOrCVR) { 
														 | 
														
														 | 
														
															     public double score(AdRankItem adRankItem, String ctrOrCVR) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         double score = 0.0f; 
														 | 
														
														 | 
														
															         double score = 0.0f; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         AdActionFeature adActionFeature = this.thompsonSamplingModel.get(adRankItem.getAdId()); 
														 | 
														
														 | 
														
															         AdActionFeature adActionFeature = this.thompsonSamplingModel.get(adRankItem.getAdId()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if(ctrOrCVR.equals("ctr")) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            score = this.betaSampler(adActionFeature.getAdClick(), adActionFeature.getAdView()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if(ctrOrCVR.equals("cvr")) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            score = this.betaSampler(adActionFeature.getAdConversion(), adActionFeature.getAdView()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (ctrOrCVR.equals("ctr")){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            int alpha_ctr = (int) adActionFeature.getAdClick() + this.alpha ; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            int beta_ctr = this.beta_click + (int)adActionFeature.getAdView() - (int)adActionFeature.getAdClick(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            score = this.betaSampler(alpha_ctr, beta_ctr); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (ctrOrCVR.equals("cvr")){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            int alpha_cvr = (int) adActionFeature.getAdClick() + this.alpha ; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            int beta_cvr = this.beta_conversion + (int)adActionFeature.getAdView() - (int)adActionFeature.getAdConversion(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            score = this.betaSampler(alpha_cvr, beta_cvr); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return score; 
														 | 
														
														 | 
														
															         return score; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 |