Wis*_*ise 5 algorithm data-mining bayesian ab-testing bandit
我使用以下行来更新每次试验中的 beta 发行版并给出 arm 推荐(我使用 scipy.stats.beta):
self.prior = (1.0,1.0)
def get_recommendation(self):
sampled_theta = []
for i in range(self.arms):
#Construct beta distribution for posterior
dist = beta(self.prior[0]+self.successes[i],
self.prior[1]+self.trials[i]-self.successes[i])
#Draw sample from beta distribution
sampled_theta += [ dist.rvs() ]
# Return the index of the sample with the largest value
return sampled_theta.index( max(sampled_theta) )
Run Code Online (Sandbox Code Playgroud)
但目前,它只适用于奖励是二元的(成功或失败)。我想修改它,使其适用于非二元奖励。(例如奖励:2300、2000,...)。我怎么做?