david-cortes / contextualbandits

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

Type error if beta_prior == "auto" and nchoices is list #59

Closed songminhak closed 2 years ago

songminhak commented 2 years ago

I found an error if beta_prior is set to be "auto" and nchoices is a list when we initialize the online contextual bandits.

Here is the error message:

File "/usr/local/lib/python3.8/dist-packages/contextualbandits/online.py", line 1894, in __init__
    beta_prior = ((3./nchoices, 4.), 2)
TypeError: unsupported operand type(s) for /: 'float' and 'list'

The beta prior should be handled depending on the type of nchoices (int or list-like).

david-cortes commented 2 years ago

Thanks for the bug report. This should be fixed now:

pip install -U contextualbandits