david-cortes / contextualbandits

Python implementations of contextual bandits algorithms
http://contextual-bandits.readthedocs.io
BSD 2-Clause "Simplified" License
750 stars 148 forks source link

If r != 0 then could be working for negative reward as well? #69

Open charalak opened 10 months ago

charalak commented 10 months ago

In the following line https://github.com/david-cortes/contextualbandits/blob/7b87efe31ffefdbc95a125d557920ab5b13105c5/contextualbandits/utils.py#L912C13-L912C34

if we replace arms_w_rew = (r > 0.) with arms_w_rew = (r != 0.) then "BootstrappedUCB" and "BootstrappedTS" could work and incorporate negative rewards (I guess).

david-cortes commented 10 months ago

Thanks for the suggestion.

There's unfortunately many other places scattered throughout the code where the assumption about binary rewards is used, such as this one: https://github.com/david-cortes/contextualbandits/blob/7b87efe31ffefdbc95a125d557920ab5b13105c5/contextualbandits/utils.py#L480

Plus other methodological aspects which specifically exploit the assumption of rewards being binary, like the usage of a beta distribution whose priors are updated iteratively, or the calculation of uncertainty in active learning criteria.

Hence, you might find that changing that line might be sufficient for allowing negative rewards for some particular combinations of input parameters, but it will not guarantee that everything else will work along with them.